Skip to content

Instantly share code, notes, and snippets.

View PJZ9n's full-sized avatar
🏠
Working from home

PJZ9n PJZ9n

🏠
Working from home
View GitHub Profile
@PJZ9n
PJZ9n / generator.php
Created April 26, 2020 16:00
1チャンクしか生成させないやつ
<?php
declare(strict_types=1);
namespace sample;
use pocketmine\level\generator\GeneratorManager;
use pocketmine\level\generator\normal\Normal;
use pocketmine\plugin\PluginBase;
@PJZ9n
PJZ9n / config.php
Created April 26, 2020 15:55
PluginBaseでConfigを使用する
<?php
declare(strict_types=1);
namespace sample;
use pocketmine\plugin\PluginBase;
class Main extends PluginBase
{
@PJZ9n
PJZ9n / command.php
Last active April 26, 2020 15:36
PMMPでPluginCommandを使うときの例
<?php
declare(strict_types=1);
namespace sample;
use pocketmine\command\Command;
use pocketmine\command\CommandExecutor;
use pocketmine\command\CommandSender;
use pocketmine\command\PluginCommand;
@PJZ9n
PJZ9n / filter.php
Created April 26, 2020 12:14
PHPのfilter_varをPMMPのコマンドで使う例
<?php
declare(strict_types=1);
$label = "pay";//送金コマンド
$args = [
"hoge",//名前
"-1"//金額
];
@PJZ9n
PJZ9n / form.php
Created April 22, 2020 23:34
jojoe77777\FormAPIを扱うサンプル。動作未確認。
<?php
declare(strict_types=1);
$form = new \jojoe77777\FormAPI\SimpleForm(function (\pocketmine\Player $player, $data): void {
if ($data === null) {
//閉じられた
return;
}
switch ($data) {
@PJZ9n
PJZ9n / form.php
Last active April 22, 2020 23:30
PocketMineでFormを扱うサンプル。動作未確認。
<?php
declare(strict_types=1);
class selectForm implements \pocketmine\form\Form
{
public function handleResponse(\pocketmine\Player $player, $data): void
{
if ($data === null) {
@PJZ9n
PJZ9n / math.php
Created April 22, 2020 01:02
二つの座標から中心の座標を求める
<?php
$ax = 0;
$ay = 0;
$bx = 500;
$by = 660;
$x = ($ax + $bx) / 2;
$y = ($ay + $by) / 2;
<?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
<?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
@PJZ9n
PJZ9n / test.php
Last active April 20, 2020 23:39
コルーチンのやつ(無名クラスではない版) 動作未確認、急いで勘で書いたからもしかしたら間違ってるかも
<?php
class TestTask extends Task
{
/** @var \Generator */
private $generator;
public function __construct(\Generator $generator)
{
$this->generator = $generator;