{"id":16013043,"url":"https://github.com/endermanbugzjfc/zekcau","last_synced_at":"2026-04-11T21:31:19.649Z","repository":{"id":107500084,"uuid":"523412168","full_name":"Endermanbugzjfc/ZekCau","owner":"Endermanbugzjfc","description":"隻抽！ Dual-players combat mode for PocketMine-MP.","archived":false,"fork":false,"pushed_at":"2022-08-21T04:52:45.000Z","size":91,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-24T16:03:29.674Z","etag":null,"topics":["await","cau","combat","mode","pmmp","pocketmine","std","zek"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Endermanbugzjfc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-10T16:12:22.000Z","updated_at":"2024-08-11T07:45:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"eb0ad7d9-6b3a-4215-8e60-1db36585c534","html_url":"https://github.com/Endermanbugzjfc/ZekCau","commit_stats":{"total_commits":40,"total_committers":2,"mean_commits":20.0,"dds":0.09999999999999998,"last_synced_commit":"ef7a14c7708e15b393c42dae3a651b67a9238989"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":"Endermanbugzjfc/ExamplePlugin","purl":"pkg:github/Endermanbugzjfc/ZekCau","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Endermanbugzjfc%2FZekCau","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Endermanbugzjfc%2FZekCau/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Endermanbugzjfc%2FZekCau/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Endermanbugzjfc%2FZekCau/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Endermanbugzjfc","download_url":"https://codeload.github.com/Endermanbugzjfc/ZekCau/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Endermanbugzjfc%2FZekCau/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274759115,"owners_count":25343872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["await","cau","combat","mode","pmmp","pocketmine","std","zek"],"created_at":"2024-10-08T14:23:47.138Z","updated_at":"2025-10-17T19:59:13.484Z","avatar_url":"https://github.com/Endermanbugzjfc.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZekCau\nZekCau (Cantonese of 隻抽, means \"go it alone\") is an example implementation of PocketMine-MP dual-players combat mode using [Await-Std](https://github.com/SOF3/await-std).\n\nBut can also be used as an API (virion) or plugin for instant use.\n\n## What is combat mode\nCombat modes are enabled in pairs. Two players in the same combat mode pair can only attack / get attacked by each other. Damage cannot be dealed if they try to attack any other entity or vice versa.\n\n\u003e so combat lock of sorts\n\u003e\n\u003e -- \u003ccite\u003e[Thunder33345#9999](https://discord.com/channels/373199722573201408/430364566027763744/1006997537716183152)\u003c/cite\u003e\n# API\n## Preparation\n```php\nuse Endermanbugzjfc\\ZekCau\\CombatMode;\nuse Endermanbugzjfc\\ZekCau\\CombatSession;\nuse SOFe\\AwaitStd\\AwaitStd;\n```\nInitialize an AwaitStd instance.\n```php\n$std = AwaitStd::init($this);\n```\n## Usage\n`autoEnable()` will enable combat mode for two players when one attacks another.\n\nThe `$until` callback is called every time when they attack each other, means the combat mode timer should be reset by creating a new generator. The following code returns a sleep-generator (generator version of delayed task) of 15 seconds:\n```php\nCombatMode::autoEnable($this, new CombatSession(\n\t$std,\n\tstatic fn(CombatSession $s) : \\Generator =\u003e yield from $s-\u003estd()-\u003esleep(15 * 20),\n));\n```\nYou are not limited to just `yield from` a sleep-generator, side effects can be made too. Such as sending popups (or updating a boss bar):\n```php\nCombatMode::autoEnable($std, static function (CombatSession $s) : \\Generator {\n\tforeach ($s-\u003eplayers() as $player) {\n\t\t$player-\u003esendPopup(\"Combat mode timer resets!\");\n\t}\n\n\tyield from $std-\u003esleep(15 * 20);\n});\t\t\n```\n## Count down popup example\n```php\nCombatMode::autoEnable($this, new CombatSession($std, static function (CombatSession $s) : \\Generator {\n\t// Avoid two generators running at the same time and send overlapping popups.\n\tstatic $running = 0; // $running will not reset after this (closure) function ends because of static.\n\t$current = ++$running;\n\n\tfor ($seconds = 15; $seconds \u003e 0; $seconds--) {\n\t\tforeach ($s-\u003eplayers() as $player) {\n\t\t\t$player-\u003esendPopup(\"Combat mode count down: $seconds seconds.\");\n\t\t}\n\n\t\tyield from $std-\u003esleep(20); // Sleep 1 second.\n\t\tif ($running !== $current) {\n\t\t\treturn; // New generator is created. Stop this one to not send overlapping popups and waste system resources (redundantly creating sleep-generators).\n\t\t}\n\t}\n\n\t$running = 0;\n}));\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendermanbugzjfc%2Fzekcau","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fendermanbugzjfc%2Fzekcau","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendermanbugzjfc%2Fzekcau/lists"}