コード例 #1
0
ファイル: RPGPlayer.php プロジェクト: HelloWorld017/ToAruPG
 public function __construct(Player $player, array $skills = [], $job = 0, array $status = [], $mana = -1, $health = -1)
 {
     $this->isArmed = true;
     $this->player = $player;
     $this->job = JobManager::getJob($job);
     $this->status = new PlayerStatus($status, $this);
     $this->armorStatus = new Status([Status::MAX_HP => 0, Status::MAX_MP => 0, Status::STR => 0, Status::INT => 0, Status::DEX => 0, Status::LUK => 0]);
     $this->skillStatus = new Status([Status::MAX_HP => 0, Status::MAX_MP => 0, Status::STR => 0, Status::INT => 0, Status::DEX => 0, Status::LUK => 0]);
     $this->mana = $mana === -1 ? $this->getFinalValue(Status::MAX_MP) : $mana;
     $this->health = $health === -1 ? $this->getFinalValue(Status::MAX_HP) : $health;
     $this->skills = [];
     foreach ($skills as $skillTag) {
         $skillData = explode(";", $skillTag);
         $skill = SkillManager::getSkill($skillData[0]);
         $skill->setPlayer($this);
         if (count($skillData) > 1) {
             $skill->setLevel($skillData[1]);
         }
         $this->skills[$skill->getItem()->getId() . ";" . $skill->getItem()->getDamage()] = $skill;
         $skill->onPassiveInit();
     }
     $this->notifyXP();
     $this->finalUse = 0;
     if (ToAruPG::getConfiguration("remove-hunger", false)) {
         $this->sendAttribute(Attribute::getAttribute(ToAruPG::ATTRIBUTE_HUNGER)->setValue(0)->setMaxValue(0));
     }
 }
コード例 #2
0
ファイル: Archery.php プロジェクト: HelloWorld017/ToAruArcher
 public function onEnable()
 {
     JobManager::registerJob(new JobArcher());
     SkillManager::registerSkill(new SkillArrowRepeat());
     SkillManager::registerSkill(new SkillDash());
     SkillManager::registerSkill(new SkillDualArrow());
     SkillManager::registerSkill(new SkillExplosionArrow());
     SkillManager::registerSkill(new SkillArrowMastery());
     SkillManager::registerSkill(new SkillSplitShot());
     SkillManager::registerSkill(new SkillQuickShot());
     SkillManager::registerSkill(new SkillManaIncrease());
     SkillManager::registerSkill(new SkillBowMastery());
     SkillManager::registerSkill(new SkillLightningShot());
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     Entity::registerEntity("Khinenw\\Archer\\EffectArrow");
     ToAruPG::addAllTranslation($this->getResource("translation.yml"));
     self::$instance = $this;
 }
コード例 #3
0
ファイル: SetShop.php プロジェクト: HelloWorld017/ToAruShop
 public function buy(Player $buyer)
 {
     $rpg = ToAruPG::getInstance()->getRPGPlayerByName($buyer);
     $job = JobManager::getJob($this->jobId);
     $rpg->changeJob($job);
     foreach ($job->getSkills() as $skill) {
         $skill = SkillManager::getSkill($skill);
         if (!$skill->canBeAcquired($rpg)) {
             $buyer->sendMessage(TextFormat::RED . ToAruPG::getTranslation("SKILL_COULD_NOT_ACQUIRE", ToAruPG::getTranslation($skill->getName())));
             continue;
         }
         if ($rpg->hasSkill($skill->getId())) {
             $buyer->sendMessage(TextFormat::RED . ToAruPG::getTranslation("ALREADY_HAS_SKILL", ToAruPG::getTranslation($skill->getName())));
             continue;
         }
         $rpg->acquireSkill($skill);
     }
     EconomyAPI::getInstance()->reduceMoney($buyer, $this->cost, true, "To Aru Shop");
     $buyer->sendMessage(TextFormat::AQUA . ToAruPG::getTranslation("BOUGHT"));
 }
コード例 #4
0
ファイル: ToAruPG.php プロジェクト: HelloWorld017/ToAruPG
 public function onEnable()
 {
     @mkdir($this->getDataFolder());
     self::$instance = $this;
     self::$translation = (new Config($this->getDataFolder() . "translation.yml", Config::YAML, yaml_parse(stream_get_contents($this->getResource("translation.yml")))))->getAll();
     self::$configuration = (new Config($this->getDataFolder() . "config.yml", Config::YAML))->getAll();
     self::$pvpEnabled = self::getConfiguration("pvp-enabled", false);
     XcelUpdater::chkUpdate($this);
     $this->players = [];
     JobManager::registerJob(new JobAdventure());
     $this->getServer()->getScheduler()->scheduleRepeatingTask(new HealTask($this), 1200);
     $this->getServer()->getScheduler()->scheduleRepeatingTask(new UITask($this), 15);
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $autoSaveTerm = self::getConfiguration("auto-save", 10);
     if ($autoSaveTerm < 0) {
         $this->getLogger()->alert(TextFormat::YELLOW . "Auto save turned-off!");
     } else {
         $this->getServer()->getScheduler()->scheduleRepeatingTask(new AutoSaveTask($this), $autoSaveTerm * 60 * 20);
     }
     Attribute::addAttribute(self::ATTRIBUTE_HUNGER, "player.huger", 0, 20, 20, true);
 }
コード例 #5
0
ファイル: ToAruShop.php プロジェクト: HelloWorld017/ToAruShop
 public function onSignChange(SignChangeEvent $event)
 {
     $text = $event->getLines();
     $prefix = strtoupper($text[0]);
     if ($prefix !== "[ARUSHOP]") {
         return;
     }
     if (!$event->getPlayer()->hasPermission("arushop.create")) {
         $event->getPlayer()->sendMessage(TextFormat::RED . ToAruPG::getTranslation("NO_PERMISSION"));
         return;
     }
     $cost = $text[2];
     $meta = $text[3];
     $tag = $event->getBlock()->getX() . ";" . $event->getBlock()->getY() . ";" . $event->getBlock()->getZ() . ";" . $event->getBlock()->getLevel()->getFolderName();
     if (!is_numeric($cost) || !is_numeric($meta)) {
         $event->getPlayer()->sendMessage(TextFormat::RED . ToAruPG::getTranslation("WRONG_SHOP_META"));
         return;
     }
     switch (strtoupper($text[1])) {
         case "JOB":
             if (JobManager::getJob($meta) === null) {
                 $event->getPlayer()->sendMessage(TextFormat::RED . ToAruPG::getTranslation("WRONG_SHOP_META"));
                 return;
             }
             $this->shops[$tag] = new JobShop($meta, $cost, ToAruPG::getTranslation("TAP_ONE_MORE"));
             $meta = ToAruPG::getTranslation(JobManager::getJob($meta)->getName());
             $name = ToAruPG::getTranslation("JOB_SHOP");
             break;
         case "SKILL":
             if (SkillManager::getSkill($meta) === null) {
                 $event->getPlayer()->sendMessage(TextFormat::RED . ToAruPG::getTranslation("WRONG_SHOP_META"));
                 return;
             }
             $this->shops[$tag] = new SkillShop($meta, $cost, ToAruPG::getTranslation("TAP_ONE_MORE"));
             $meta = ToAruPG::getTranslation(SkillManager::getSkill($meta)->getName());
             $name = ToAruPG::getTranslation("SKILL_SHOP");
             break;
         case "SET":
             if (JobManager::getJob($meta) === null) {
                 $event->getPlayer()->sendMessage(TextFormat::RED . ToAruPG::getTranslation("WRONG_SHOP_META"));
                 return;
             }
             $this->shops[$tag] = new SetShop($meta, $cost, ToAruPG::getTranslation("TAP_ONE_MORE"));
             $meta = ToAruPG::getTranslation(JobManager::getJob($meta)->getName());
             $name = ToAruPG::getTranslation("SET_SHOP");
             break;
         default:
             $event->getPlayer()->sendMessage(TextFormat::RED . ToAruPG::getTranslation("WRONG_SHOP_META"));
             return;
     }
     $this->saveShops();
     $event->setLine(0, $name);
     $event->setLine(1, TextFormat::AQUA . $meta);
     $event->setLine(2, $cost . EconomyAPI::getInstance()->getMonetaryUnit());
     $event->setLine(3, "");
     $event->getPlayer()->sendMessage(TextFormat::AQUA . ToAruPG::getTranslation("SHOP_CREATED"));
 }
コード例 #6
0
ファイル: JobShop.php プロジェクト: HelloWorld017/ToAruShop
 public function buy(Player $buyer)
 {
     ToAruPG::getInstance()->getRPGPlayerByName($buyer)->changeJob(JobManager::getJob($this->jobId));
     EconomyAPI::getInstance()->reduceMoney($buyer, $this->cost, true, "To Aru Shop");
     $buyer->sendMessage(TextFormat::AQUA . ToAruPG::getTranslation("BOUGHT"));
 }