This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //とても単純な例で、そのまま使うことを前提としていません | |
| public function onJoin(PlayerJoinEvent $event): void { | |
| //プレイヤーが入ったときに、Web側に所持金データを送信する | |
| $ch = curl_init("http://aaa.com/money.php"); | |
| curl_setopt($ch, CURLOPT_POST, true); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ | |
| "name" => $event->getPlayer()->getName(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //とても単純な例で、そのまま使うことを前提としていません | |
| //同一ディレクトリに所持金記録用のmoney.jsonがあるとする | |
| //処理金を返す | |
| function getMoney(string $name): string { | |
| $moneys = json_decode(file_get_contents("money.json"), true); | |
| return $moneys[$name]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** @var $pos pocketmine\math\Vector3 */ | |
| $chunkX = $pos->getFloorX() >> 4; | |
| $chunkZ = $pos->getFloorZ() >> 4; | |
| //参考: https://github.com/pmmp/PocketMine-MP/blob/stable/src/pocketmine/level/Level.php#L2306 | |
| /** @var $pos pocketmine\math\Vector3 */ | |
| $chunkInX = $pos->getFloorX() & 0x0f; | |
| $chunkInZ = $pos->getFloorZ() & 0x0f; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use pocketmine\math\Vector3; | |
| /** | |
| * 二つの座標からその中の全座標を取得する | |
| * | |
| * @param Vector3 $start | |
| * @param Vector3 $end | |
| * @param int $space 取得する間隔(細かさ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function test(): \Generator | |
| { | |
| for ($i = 1; $i <= 5; $i++) { | |
| yield;//ここでGeneratorを返す(難しい) 位置が違った,修正済み | |
| echo "Number is" . $i . PHP_EOL; | |
| } | |
| } | |
| $this->getScheduler()->scheduleRepeatingTask(new class(test()) extends Task { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class TestTask extends Task | |
| { | |
| /** @var \Generator */ | |
| private $generator; | |
| public function __construct(\Generator $generator) | |
| { | |
| $this->generator = $generator; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Copyright (c) 2020 NewCore. | |
| * | |
| * This file is part of NewCore. | |
| * | |
| * NewCore is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License, or |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Copyright (c) 2020 NewCore. | |
| * | |
| * This file is part of NewCore. | |
| * | |
| * NewCore is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License, or |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $ax = 0; | |
| $ay = 0; | |
| $bx = 500; | |
| $by = 660; | |
| $x = ($ax + $bx) / 2; | |
| $y = ($ay + $by) / 2; |