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 / todaytweets.php
Last active June 8, 2020 17:38
当日のツイートをすべて取得
<?php
/**
* Copyright (c) 2020 PJZ9n.
*
* This file is part of Hello-TwitterAPI.
*
* Hello-TwitterAPI 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
declare(strict_types=1);
class a
{
/** @var string */
private static $foo;
public static function getFoo(): string
<?php
$rightClickBlockFilter = function (PlayerInteractEvent $event) use ($player): bool {
return $event->getPlayer() === $player && $event->getAction() === PlayerInteractEvent::RIGHT_CLICK_BLOCK;
};
$ignoreCancelled = function (Cancellable $cancellable): bool {
return !$cancellable->isCancelled();
};
<?php
start($this)->run(function () {
while (true) {
/** @var PlayerEditBookEvent $event */
$event = yield listen(PlayerEditBookEvent::class);
if ($event->getAction() !== PlayerEditBookEvent::ACTION_SIGN_BOOK) {
continue;
}
$book = $event->getNewBook();
<?php
start($this)->run(function () {
$lastTick = [];
while (true) {
return;
/** @var PlayerInteractEvent $event */
$event = yield listen(PlayerInteractEvent::class);
$player = $event->getPlayer();
$name = $player->getName();
<?php
declare(strict_types=1);
start($this)->run(function (EventStream $eventStream) {
while (true) {
/** @var PlayerJoinEvent $event */
$event = yield listen(PlayerJoinEvent::class);
$player = $event->getPlayer();
<?php
/**
* @license GNU Lesser General Public License v2.1
* @author FlowyProject(https://github.com/FlowyProject/)
*/
declare(strict_types=1);
namespace PJZ9n\Example;
@PJZ9n
PJZ9n / validate.php
Created June 2, 2020 17:30
Particle/Validatorを使用したバリデーションのサンプル
<?php
declare(strict_types=1);
use Particle\Validator\Validator;
$input = [
"enabled" => true,
"items" => [
[
@PJZ9n
PJZ9n / Main.php
Created June 2, 2020 13:41
原石破壊
<?php
declare(strict_types=1);
namespace Example;
use pocketmine\block\Block;
use pocketmine\event\block\BlockBreakEvent;
use pocketmine\event\Listener;
use pocketmine\plugin\PluginBase;
@PJZ9n
PJZ9n / dropitem.php
Created May 27, 2020 20:38
アイテムをドロップさせる
<?php
/** @var \pocketmine\level\Level $level */
$pos = new Vector3(1, 2, 3);
$item = ItemFactory::get(Item::STONE);
$level->dropItem($pos, $item);