/** * @param PlayerQuitEvent $event * @priority MONITOR */ public function onPlayerQuit(PlayerQuitEvent $event) { if ($this->plugin->isSkinStored($event->getPlayer())) { $this->plugin->removeSkinData($event->getPlayer()); } $this->plugin->clearTouchMode($event->getPlayer()); }
/** * Converts skin data into an image file * @param Human $human */ public static function toImage(Human $human) { if (extension_loaded("gd")) { //TODO: Work on data-to-image conversion } else { SkinTools::getInstance()->getServer()->getLogger()->critical("Failed to create image from skin data, PHP extension \"GD\" wasn't found."); } }
/** * @param CommandSender $sender * @param string $label * @param string[] $args * @return bool */ public function execute(CommandSender $sender, $label, array $args) { if (!$this->testPermission($sender)) { return false; } if (isset($args[0])) { switch (strtolower($args[0])) { case "file": if (isset($args[1])) { if ($player = $sender->getServer()->getPlayer($args[1])) { SkinConverter::toFile($player); $sender->sendMessage(TextFormat::GREEN . "Saved " . $player->getName() . "'s skin as a data file."); } else { $sender->sendMessage(TextFormat::RED . "That player could not be found."); } } else { $sender->sendMessage(TextFormat::RED . "Please specify a valid player."); } return true; case "help": $this->sendCommandHelp($sender); return true; /* case "image": //TODO: Fully implement command return true; */ /* case "image": //TODO: Fully implement command return true; */ case "morph": if ($sender instanceof Player) { if (isset($args[1])) { if ($player = $sender->getServer()->getPlayer($args[1])) { $this->plugin->setStolenSkin($sender, $player); $sender->sendMessage(TextFormat::GREEN . "You got " . $player->getName() . "'s skin."); } else { $sender->sendMessage(TextFormat::RED . "That player could not be found."); } } else { $sender->sendMessage(TextFormat::RED . "Please specify a valid player."); } } else { $sender->sendMessage(TextFormat::RED . "Please run this command in-game."); } return true; case "restore": if ($sender instanceof Player) { $sender->setSkin($this->plugin->retrieveSkinData($sender)); $sender->sendMessage(TextFormat::GREEN . "Your original skin has been restored."); } else { $sender->sendMessage(TextFormat::RED . "Please run this command in-game."); } return true; /* case "swap": if($sender instanceof Player){ //TODO: Fully implement command } else{ $sender->sendMessage(TextFormat::RED."Please run this command in-game."); } return true; */ /* case "swap": if($sender instanceof Player){ //TODO: Fully implement command } else{ $sender->sendMessage(TextFormat::RED."Please run this command in-game."); } return true; */ case "touch": if ($sender instanceof Player) { if (isset($args[1])) { switch (strtolower($args[1])) { case (string) SkinTools::NONE: case "n": case "none": $this->plugin->setTouchMode($sender); $sender->sendMessage(TextFormat::GREEN . "Skin touch mode set to NONE."); break; case (string) SkinTools::GIVE: case "g": case "give": $this->plugin->setTouchMode($sender, SkinTools::GIVE); $sender->sendMessage(TextFormat::GREEN . "Skin touch mode set to GIVE."); break; case (string) SkinTools::STEAL: case "s": case "steal": $this->plugin->setTouchMode($sender, SkinTools::STEAL); $sender->sendMessage(TextFormat::GREEN . "Skin touch mode set to STEAL."); break; default: $sender->sendMessage(TextFormat::RED . "\"" . $args[1] . "\" is not a valid touch mode."); break; } } else { $sender->sendMessage(TextFormat::YELLOW . "Your touch mode is " . $this->plugin->getTouchMode($sender) . "."); } } else { $sender->sendMessage(TextFormat::RED . "Please run this command in-game."); } return true; default: $sender->sendMessage("Usage: /skintools <sub-command> [parameters]"); return false; } } else { $this->sendCommandHelp($sender); return false; } }