Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Tungst_thoai;
- use pocketmine\plugin\PluginBase;
- use pocketmine\Player;
- use pocketmine\Server;
- use pocketmine\event\Listener;
- use pocketmine\command\Command;
- use pocketmine\command\CommandSender;
- use pocketmine\event\Event;
- use pocketmine\event\player\PlayerJoinEvent;
- class Main extends PluginBase implements Listener {
- public function onEnable(){
- $this->getLogger()->info("thoai");
- $this->getServer()->getPluginManager()->registerEvents($this, $this);
- $this->saveDefaultConfig();
- }
- public function onCommand(CommandSender $sender, Command $command, String $label, array $args) : bool {
- if(strtolower($command->getName()) == "thoai"){
- if(!isset($args[0])){
- $sender->sendMessage("Dùng /thoai <caijdo>");
- return false;
- }
- if(!isset($this->getConfig()->getNested('thoai')[$args[0]])){
- $sender->sendMessage("Không thấy thoại '".$args[0]."'");
- return false;
- }
- $sender->sendMessage($this->getConfig()->getNested('thoai')[$args[0]]);
- }
- else if(strtolower($command->getName()) == "addthoai"){
- if(!$sender instanceof Player){$sender->sendMessage("Use in game");return false;}
- $this->newform($sender,"");
- }
- return true;
- return true;
- }
- public function newform($player,$err){
- $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI");
- $form = $api->createCustomForm(function (Player $player, $data){
- $api1 = $this->getServer()->getPluginManager()->getPlugin("EconomyAPI");
- $result = $data;
- if($result === null){
- return false;
- }
- if(!isset($result[1]) || !isset($result[2])){
- $this->newform($player,"§cPlease type thoai's name and the msg\n");
- return false;
- }
- $thoainame = $result[1]; $thoai = $result[2];
- $this->getConfig()->setNested("thoai.$thoainame",$thoai);
- $this->getConfig()->setAll($this->getConfig()->getAll());
- $this->getConfig()->save();
- $this->newform($player,"§aCreate thoai successfull, name: $thoainame , msg: $thoai");
- });
- $form->setTitle("§0Create §cthoai");
- $form->addLabel("$err");
- $form->addInput("Thoai's name:");
- $form->addInput("Message:");
- $form->sendToPlayer($player);
- return $form;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement