improved player actions
This commit is contained in:
parent
28a9054c0d
commit
b72e036cf7
@ -3,6 +3,7 @@
|
||||
namespace ManiaControl\Players;
|
||||
|
||||
|
||||
use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
class PlayerActions {
|
||||
@ -28,32 +29,97 @@ class PlayerActions {
|
||||
/**
|
||||
* Forces a Player to a certain team
|
||||
* @param $adminLogin
|
||||
* @param $login
|
||||
* @param $targetLogin
|
||||
* @param $teamId
|
||||
*/
|
||||
public function forcePlayerToTeam($adminLogin, $login, $teamId){
|
||||
$this->maniaControl->client->query('ForcePlayerTeam', $login, $teamId); //TODO bestätigung und chatnachricht
|
||||
public function forcePlayerToTeam($adminLogin, $targetLogin, $teamId){ //TODO get used by playercommands
|
||||
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->playerManager->getPlayer($targetLogin);
|
||||
if($target->isSpectator){
|
||||
$success = $this->maniaControl->client->query('ForceSpectator', $targetLogin, self::SPECTATOR_PLAYER);
|
||||
if (!$success) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$success = $this->maniaControl->client->query('ForcePlayerTeam', $targetLogin, $teamId); //TODO bestätigung und chatnachricht
|
||||
|
||||
if (!$success) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
|
||||
return;
|
||||
}
|
||||
|
||||
if($teamId == self::BLUE_TEAM)
|
||||
$this->maniaControl->chat->sendInformation('$<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Blue-Team!');
|
||||
else if($teamId == self::RED_TEAM)
|
||||
$this->maniaControl->chat->sendInformation('$<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Red-Team!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces a Player to spectator
|
||||
* @param $adminLogin
|
||||
* @param $login
|
||||
* @param $targetLogin
|
||||
* @param int $spectatorState
|
||||
*/
|
||||
public function forcePlayerToSpectator($adminLogin, $login, $spectatorState = self::SPECTATOR_BUT_KEEP_SELECTABLE){
|
||||
$this->maniaControl->client->query('ForceSpectator', $login, $spectatorState); //TODO bestätigung und chatnachricht
|
||||
public function forcePlayerToSpectator($adminLogin, $targetLogin, $spectatorState = self::SPECTATOR_BUT_KEEP_SELECTABLE){ //TODO get used by playercommands
|
||||
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->playerManager->getPlayer($targetLogin);
|
||||
|
||||
$success = $this->maniaControl->client->query('ForceSpectator', $targetLogin, $spectatorState); //TODO bestätigung und chatnachricht
|
||||
if (!$success) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->maniaControl->chat->sendInformation('$<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> to spectator!'); //TODO add admin title
|
||||
}
|
||||
|
||||
/**
|
||||
* Warn a Player
|
||||
* @param $adminLogin
|
||||
* @param $login
|
||||
* @param string $message
|
||||
*/
|
||||
public function warnPlayer($adminLogin, $login, $message = ''){
|
||||
|
||||
}
|
||||
|
||||
public function kickPlayer($adminLogin, $login, $message = ''){
|
||||
|
||||
/**
|
||||
* Kicks a Player
|
||||
* @param $adminLogin
|
||||
* @param $targetLogin
|
||||
* @param string $message
|
||||
*/
|
||||
public function kickPlayer($adminLogin, $targetLogin, $message = ''){
|
||||
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->playerManager->getPlayer($targetLogin);
|
||||
|
||||
$success = $this->maniaControl->client->query('Kick', $target->login, $message); //TODO bestätigung und chatnachricht
|
||||
if (!$success) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->chat->sendInformation('$<' . $admin->nickname . '$> kicked $<' . $target->nickname . '$>!'); //TODO add admin title
|
||||
}
|
||||
|
||||
public function banPlayer($adminLogin, $login, $message = ''){
|
||||
/**
|
||||
* Bans a Player
|
||||
* @param $adminLogin
|
||||
* @param $targetLogin
|
||||
* @param string $message
|
||||
*/
|
||||
public function banPlayer($adminLogin, $targetLogin, $message = ''){
|
||||
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->playerManager->getPlayer($targetLogin);
|
||||
|
||||
$success = $this->maniaControl->client->query('Ban', $target->login, $message); //TODO bestätigung und chatnachricht
|
||||
|
||||
if (!$success) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->chat->sendInformation('$<' . $admin->nickname . '$> banned $<' . $target->nickname . '$>!'); //TODO add admin title
|
||||
}
|
||||
}
|
@ -92,12 +92,8 @@ class PlayerCommands implements CommandListener {
|
||||
if (isset($params[2])) {
|
||||
$message = $params[2];
|
||||
}
|
||||
$success = $this->maniaControl->client->query('Kick', $target->login, $message);
|
||||
if (!$success) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> kicked $<' . $target->nickname . '$>!');
|
||||
|
||||
$this->maniaControl->playerManager->playerActions->kickPlayer($player->login, $target, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,12 +38,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
|
||||
const ACTION_PLAYER_ADV = 'PlayerList.PlayerAdvancedActions';
|
||||
const ACTION_CLOSE_PLAYER_ADV = 'PlayerList.ClosePlayerAdvWidget';
|
||||
const ACTION_WARN_PLAYER = ' PlayerList.WarnPlayer';
|
||||
const ACTION_KICK_PLAYER = ' PlayerList.KickPlayer';
|
||||
const ACTION_BAN_PLAYER = ' PlayerList.BanPlayer';
|
||||
const ACTION_ADD_AS_MASTER = ' PlayerList.PlayerAddAsMaster';
|
||||
const ACTION_ADD_AS_ADMIN = ' PlayerList.PlayerAddAsAdmin';
|
||||
const ACTION_ADD_AS_MOD = ' PlayerList.PlayerAddAsModerator';
|
||||
const ACTION_WARN_PLAYER = 'PlayerList.WarnPlayer';
|
||||
const ACTION_KICK_PLAYER = 'PlayerList.KickPlayer';
|
||||
const ACTION_BAN_PLAYER = 'PlayerList.BanPlayer';
|
||||
const ACTION_ADD_AS_MASTER = 'PlayerList.PlayerAddAsMaster';
|
||||
const ACTION_ADD_AS_ADMIN = 'PlayerList.PlayerAddAsAdmin';
|
||||
const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator';
|
||||
|
||||
/**
|
||||
* Private properties
|
||||
|
@ -176,8 +176,10 @@ class PlayerManager implements CallbackListener {
|
||||
* @param array $callback
|
||||
*/
|
||||
public function playerInfoChanged(array $callback){
|
||||
//TODO something on playerjoin not working here (maybe because it get called before player join
|
||||
$player = $this->getPlayer($callback[1][0]['Login']);
|
||||
if($player == null)
|
||||
return;
|
||||
|
||||
$player->teamId = $callback[1][0]["TeamId"];
|
||||
$player->isSpectator = $callback[1][0]["SpectatorStatus"];
|
||||
$player->ladderRank = $callback[1][0]["LadderRanking"];
|
||||
|
Loading…
Reference in New Issue
Block a user