@@ -22,67 +22,67 @@ |
||
22 | 22 | |
23 | 23 | class Main extends PluginBase implements Listener |
24 | 24 | { |
25 | - private $banapi; |
|
26 | - protected $spamplayers = []; |
|
25 | + private $banapi; |
|
26 | + protected $spamplayers = []; |
|
27 | 27 | |
28 | - public function onEnable(): void |
|
29 | - { |
|
30 | - $this->getServer()->getPluginManager()->registerEvents($this, $this); |
|
31 | - $this->banapi = $this->getServer()->getPluginManager()->getPlugin("BanAPI"); |
|
32 | - $this->getScheduler()->scheduleRepeatingTask(new CheckPlayerTask($this), 20); |
|
33 | - } |
|
28 | + public function onEnable(): void |
|
29 | + { |
|
30 | + $this->getServer()->getPluginManager()->registerEvents($this, $this); |
|
31 | + $this->banapi = $this->getServer()->getPluginManager()->getPlugin("BanAPI"); |
|
32 | + $this->getScheduler()->scheduleRepeatingTask(new CheckPlayerTask($this), 20); |
|
33 | + } |
|
34 | 34 | |
35 | - public function onToggleFlight(PlayerToggleFlightEvent $event): void |
|
36 | - { |
|
37 | - $player = $event->getPlayer(); |
|
38 | - if (!$player->isOp()) { |
|
39 | - if ($event->isFlying()) { |
|
40 | - $this->banapi->addBan($player->getName(), $player->getAddress(), "Flying(飛行)", "AntiCheat", true); |
|
41 | - } else { |
|
42 | - $this->banapi->addBan($player->getName(), $player->getAddress(), "Flying(飛行)", "AntiCheat", true); |
|
43 | - } |
|
44 | - } |
|
45 | - } |
|
35 | + public function onToggleFlight(PlayerToggleFlightEvent $event): void |
|
36 | + { |
|
37 | + $player = $event->getPlayer(); |
|
38 | + if (!$player->isOp()) { |
|
39 | + if ($event->isFlying()) { |
|
40 | + $this->banapi->addBan($player->getName(), $player->getAddress(), "Flying(飛行)", "AntiCheat", true); |
|
41 | + } else { |
|
42 | + $this->banapi->addBan($player->getName(), $player->getAddress(), "Flying(飛行)", "AntiCheat", true); |
|
43 | + } |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | - public function onReceive(DataPacketReceiveEvent $event) |
|
48 | - { |
|
49 | - $packet = $event->getPacket(); |
|
50 | - if ($packet instanceof LoginPacket) { |
|
51 | - if ($packet->serverAddress === "mcpeproxy.tk" or $packet->serverAddress === "165.227.79.111") { |
|
52 | - $this->banapi->addBan($packet->username, $packet->serverAddress, "PROXY(プロキシ)", "AntiCheat", true); |
|
53 | - } |
|
54 | - if ($packet->clientId === 0) { |
|
55 | - $this->banapi->addBan($packet->username, $packet->serverAddress, "Toolbox(ツール)", "AntiCheat", true); |
|
56 | - } |
|
57 | - } |
|
58 | - } |
|
47 | + public function onReceive(DataPacketReceiveEvent $event) |
|
48 | + { |
|
49 | + $packet = $event->getPacket(); |
|
50 | + if ($packet instanceof LoginPacket) { |
|
51 | + if ($packet->serverAddress === "mcpeproxy.tk" or $packet->serverAddress === "165.227.79.111") { |
|
52 | + $this->banapi->addBan($packet->username, $packet->serverAddress, "PROXY(プロキシ)", "AntiCheat", true); |
|
53 | + } |
|
54 | + if ($packet->clientId === 0) { |
|
55 | + $this->banapi->addBan($packet->username, $packet->serverAddress, "Toolbox(ツール)", "AntiCheat", true); |
|
56 | + } |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | - public function onCommandPreprocess(PlayerCommandPreprocessEvent $event) |
|
61 | - { |
|
62 | - $player = $event->getPlayer(); |
|
63 | - $cooldown = microtime(true); |
|
64 | - if (isset($this->spamplayers[$player->getName()])) { |
|
65 | - if (($cooldown - $this->spamplayers[$player->getName()]['cooldown']) < 2) { |
|
66 | - $player->sendMessage("§7クールダウン中です。"); |
|
67 | - $event->setCancelled(true); |
|
68 | - } |
|
69 | - } |
|
70 | - $this->spamplayers[$player->getName()]["cooldown"] = $cooldown; |
|
71 | - } |
|
60 | + public function onCommandPreprocess(PlayerCommandPreprocessEvent $event) |
|
61 | + { |
|
62 | + $player = $event->getPlayer(); |
|
63 | + $cooldown = microtime(true); |
|
64 | + if (isset($this->spamplayers[$player->getName()])) { |
|
65 | + if (($cooldown - $this->spamplayers[$player->getName()]['cooldown']) < 2) { |
|
66 | + $player->sendMessage("§7クールダウン中です。"); |
|
67 | + $event->setCancelled(true); |
|
68 | + } |
|
69 | + } |
|
70 | + $this->spamplayers[$player->getName()]["cooldown"] = $cooldown; |
|
71 | + } |
|
72 | 72 | |
73 | - public function onDamage(EntityDamageEvent $event) |
|
74 | - { |
|
75 | - $entity = $event->getEntity(); |
|
76 | - if ($event instanceof EntityDamageByEntityEvent and $entity instanceof Player) { |
|
77 | - $damager = $event->getDamager(); |
|
78 | - if ($damager instanceof Player) { |
|
79 | - if ($damager->getGamemode() === Player::CREATIVE or $damager->getInventory()->getItemInHand()->getId() === Item::BOW) { |
|
80 | - return; |
|
81 | - } |
|
82 | - if ($damager->distance($entity) > 3.9) { |
|
83 | - $event->setCancelled(true); |
|
84 | - } |
|
85 | - } |
|
86 | - } |
|
87 | - } |
|
73 | + public function onDamage(EntityDamageEvent $event) |
|
74 | + { |
|
75 | + $entity = $event->getEntity(); |
|
76 | + if ($event instanceof EntityDamageByEntityEvent and $entity instanceof Player) { |
|
77 | + $damager = $event->getDamager(); |
|
78 | + if ($damager instanceof Player) { |
|
79 | + if ($damager->getGamemode() === Player::CREATIVE or $damager->getInventory()->getItemInHand()->getId() === Item::BOW) { |
|
80 | + return; |
|
81 | + } |
|
82 | + if ($damager->distance($entity) > 3.9) { |
|
83 | + $event->setCancelled(true); |
|
84 | + } |
|
85 | + } |
|
86 | + } |
|
87 | + } |
|
88 | 88 | } |
@@ -13,23 +13,23 @@ |
||
13 | 13 | |
14 | 14 | abstract class PluginTask extends Task |
15 | 15 | { |
16 | - /** @var Plugin */ |
|
17 | - protected $owner; |
|
16 | + /** @var Plugin */ |
|
17 | + protected $owner; |
|
18 | 18 | |
19 | - /** |
|
20 | - * PluginTask constructor. |
|
21 | - * @param Plugin $plugin |
|
22 | - */ |
|
23 | - public function __construct(Plugin $plugin) |
|
24 | - { |
|
25 | - $this->owner = $plugin; |
|
26 | - } |
|
19 | + /** |
|
20 | + * PluginTask constructor. |
|
21 | + * @param Plugin $plugin |
|
22 | + */ |
|
23 | + public function __construct(Plugin $plugin) |
|
24 | + { |
|
25 | + $this->owner = $plugin; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * @return Plugin |
|
30 | - */ |
|
31 | - final public function getOwner(): Plugin |
|
32 | - { |
|
33 | - return $this->owner; |
|
34 | - } |
|
28 | + /** |
|
29 | + * @return Plugin |
|
30 | + */ |
|
31 | + final public function getOwner(): Plugin |
|
32 | + { |
|
33 | + return $this->owner; |
|
34 | + } |
|
35 | 35 | } |
@@ -13,20 +13,20 @@ |
||
13 | 13 | |
14 | 14 | class CheckPlayerTask extends PluginTask |
15 | 15 | { |
16 | - protected $banapi; |
|
16 | + protected $banapi; |
|
17 | 17 | |
18 | - public function __construct(Main $plugin) |
|
19 | - { |
|
20 | - parent::__construct($plugin); |
|
21 | - $this->banapi = $this->owner->getServer()->getPluginManager()->getPlugin("BanAPI"); |
|
22 | - } |
|
18 | + public function __construct(Main $plugin) |
|
19 | + { |
|
20 | + parent::__construct($plugin); |
|
21 | + $this->banapi = $this->owner->getServer()->getPluginManager()->getPlugin("BanAPI"); |
|
22 | + } |
|
23 | 23 | |
24 | - public function onRun(int $currentTick) |
|
25 | - { |
|
26 | - foreach ($this->owner->getServer()->getOnlinePlayers() as $player) { |
|
27 | - if ($player->isOp()) return; |
|
28 | - if (!$player->isFlying()) return; |
|
29 | - $this->banapi->addBan($player->getName(), "Flying(飛行)", "AntiCheat", true); |
|
30 | - } |
|
31 | - } |
|
24 | + public function onRun(int $currentTick) |
|
25 | + { |
|
26 | + foreach ($this->owner->getServer()->getOnlinePlayers() as $player) { |
|
27 | + if ($player->isOp()) return; |
|
28 | + if (!$player->isFlying()) return; |
|
29 | + $this->banapi->addBan($player->getName(), "Flying(飛行)", "AntiCheat", true); |
|
30 | + } |
|
31 | + } |
|
32 | 32 | } |
33 | 33 | \ No newline at end of file |