mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-26 05:14:05 +00:00
Player: drop isAdmin from kick(), closes #3275
This commit is contained in:
parent
67247b2e81
commit
5a33dbd4c6
@ -81,7 +81,7 @@ class BanIpCommand extends VanillaCommand{
|
|||||||
|
|
||||||
foreach($sender->getServer()->getOnlinePlayers() as $player){
|
foreach($sender->getServer()->getOnlinePlayers() as $player){
|
||||||
if($player->getNetworkSession()->getIp() === $ip){
|
if($player->getNetworkSession()->getIp() === $ip){
|
||||||
$player->kick($reason !== "" ? $reason : "IP banned.");
|
$player->kick("Banned by admin. Reason: " . ($reason !== "" ? $reason : "IP banned."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class KickCommand extends VanillaCommand{
|
|||||||
$reason = trim(implode(" ", $args));
|
$reason = trim(implode(" ", $args));
|
||||||
|
|
||||||
if(($player = $sender->getServer()->getPlayer($name)) instanceof Player){
|
if(($player = $sender->getServer()->getPlayer($name)) instanceof Player){
|
||||||
$player->kick($reason);
|
$player->kick("Kicked by admin." . ($reason !== "" ? "Reason: " . $reason : ""));
|
||||||
if($reason !== ""){
|
if($reason !== ""){
|
||||||
Command::broadcastCommandMessage($sender, new TranslationContainer("commands.kick.success.reason", [$player->getName(), $reason]));
|
Command::broadcastCommandMessage($sender, new TranslationContainer("commands.kick.success.reason", [$player->getName(), $reason]));
|
||||||
}else{
|
}else{
|
||||||
|
@ -1909,22 +1909,15 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
*
|
*
|
||||||
* @param TranslationContainer|string $quitMessage
|
* @param TranslationContainer|string $quitMessage
|
||||||
*/
|
*/
|
||||||
public function kick(string $reason = "", bool $isAdmin = true, $quitMessage = null) : bool{
|
public function kick(string $reason = "", $quitMessage = null) : bool{
|
||||||
$ev = new PlayerKickEvent($this, $reason, $quitMessage ?? $this->getLeaveMessage());
|
$ev = new PlayerKickEvent($this, $reason, $quitMessage ?? $this->getLeaveMessage());
|
||||||
$ev->call();
|
$ev->call();
|
||||||
if(!$ev->isCancelled()){
|
if(!$ev->isCancelled()){
|
||||||
$reason = $ev->getReason();
|
$reason = $ev->getReason();
|
||||||
$message = $reason;
|
|
||||||
if($isAdmin){
|
|
||||||
if(!$this->isBanned()){
|
|
||||||
$message = "Kicked by admin." . ($reason !== "" ? " Reason: " . $reason : "");
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if($reason === ""){
|
if($reason === ""){
|
||||||
$message = "disconnectionScreen.noReason";
|
$reason = "disconnectionScreen.noReason";
|
||||||
}
|
}
|
||||||
}
|
$this->disconnect($reason, $ev->getQuitMessage());
|
||||||
$this->disconnect($message, $ev->getQuitMessage());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1936,8 +1929,8 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
* Removes the player from the server. This cannot be cancelled.
|
* Removes the player from the server. This cannot be cancelled.
|
||||||
* This is used for remote disconnects and for uninterruptible disconnects (for example, when the server shuts down).
|
* This is used for remote disconnects and for uninterruptible disconnects (for example, when the server shuts down).
|
||||||
*
|
*
|
||||||
* Note for plugin developers: Prefer kick() with the isAdmin flag set to kick without the "Kicked by admin" part
|
* Note for plugin developers: Prefer kick() instead of this method.
|
||||||
* instead of this method. This way other plugins can have a say in whether the player is removed or not.
|
* That way other plugins can have a say in whether the player is removed or not.
|
||||||
*
|
*
|
||||||
* @param string $reason Shown to the player, usually this will appear on their disconnect screen.
|
* @param string $reason Shown to the player, usually this will appear on their disconnect screen.
|
||||||
* @param TranslationContainer|string $quitMessage Message to broadcast to online players (null will use default)
|
* @param TranslationContainer|string $quitMessage Message to broadcast to online players (null will use default)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user