Skip to content

Commit 2039320

Browse files
authored
Add files via upload
1 parent 0fcf9cb commit 2039320

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

SpiderMan.php

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
/**
3+
* @name SpiderMan
4+
* @author alvin0319
5+
* @main alvin0319\SpiderMan
6+
* @version 1.0.0
7+
* @api 4.0.0
8+
*/
9+
namespace alvin0319;
10+
11+
/**
12+
* 이 플러그인은 EconomyAPI 플러그인이 사용되므로 EconomyAPI 플러그인이 없을시 작동되지 않습니다.
13+
*/
14+
use pocketmine\Player;
15+
use pocketmine\plugin\PluginBase;
16+
use pocketmine\event\Listener;
17+
use pocketmine\scheduler\Task;
18+
use pocketmine\utils\Config;
19+
use pocketmine\command\CommandSender;
20+
use pocketmine\command\Command;
21+
use pocketmine\command\PluginCommand;
22+
23+
class SpiderMan extends PluginBase implements Listener {
24+
public function onEnable() : void{
25+
//$this->getServer()->getPluginManager()->registerEvent($this, $this);
26+
@mkdir ($this->getDataFolder());
27+
$this->config = new Config($this->getDataFolder() . "Config.yml", Config::YAML, [
28+
"money" => "100000",
29+
"plugin-prefix" => "§b§l[ §f벽타기 §b] §f",
30+
"climb-time" => "60",
31+
"cmd" => "climb"
32+
]);
33+
$this->db = $this->config->getAll();
34+
$this->money = $this->getServer()->getPluginManager()->getPlugin("EconomyAPI");
35+
$this->cmd = new PluginCommand($this->db["cmd"], $this);
36+
$this->cmd->setDescription("A ClimbCommand");
37+
$this->getServer()->getCommandMap()->register ($this->db["cmd"], $this->cmd);
38+
}
39+
public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool{
40+
if ($command->getName() === $this->db["cmd"]) {
41+
if (! isset ($args[0])) {
42+
$sender->sendMessage($this->db["plugin-prefix"] . "/" . $this->db["cmd"] . " 실행");
43+
return true;
44+
}
45+
if ($args[0] === "실행") {
46+
if (! $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")) {
47+
$sender->sendMessage($this->db["plugin-prefix"] . "EconomyAPI 플러그인이 없습니다");
48+
return true;
49+
}
50+
if ($this->money->myMoney($sender) < $this->db["money"]) {
51+
$sender->sendMessage($this->db["plugin-prefix"] . "돈이 부족합니다. 필요한 금액: " . $this->db["money"] . "");
52+
return true;
53+
}
54+
$this->money->reduceMoney($sender, $this->db["money"]);
55+
$sender->setCanClimbWalls(true);
56+
$sender->sendMessage($this->db["plugin-prefix"] . "벽타기가 활성화되었습니다");
57+
$this->getScheduler()->scheduleDelayedTask(new class ($this, $sender) extends Task {
58+
private $owner, $player;
59+
60+
public function __construct(SpiderMan $owner, Player $player) {
61+
$this->owner = $owner;
62+
$this->player = $player;
63+
}
64+
public function onRun(int $currentTick) {
65+
$this->player->setCanClimbWalls(false);
66+
$this->player->sendMessage ($this->owner->db["plugin-prefix"] . "벽타기 시간이 끝났습니다");
67+
}
68+
}, $this->db["climb-time"] * 20);
69+
}
70+
}
71+
return true;
72+
}
73+
}

0 commit comments

Comments
 (0)