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
<?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
start($this)->run(function () {
$lastTick = [];
while (true) {
return;
/** @var PlayerInteractEvent $event */
$event = yield listen(PlayerInteractEvent::class);
$player = $event->getPlayer();
$name = $player->getName();
<?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
$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
declare(strict_types=1);
class a
{
/** @var string */
private static $foo;
public static function getFoo(): string
@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
@PJZ9n
PJZ9n / twitter.php
Created June 8, 2020 19:37
個人用、本番環境用ではない、テスト用。
<?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
@PJZ9n
PJZ9n / tuihaibot.php
Created June 10, 2020 22:46
ツイ廃botのソースコード、とりあえず動くレベルの最悪な実装です。少しでも弄ると壊れます。
<?php
/**
* Copyright (c) 2020 PJZ9n.
*
* This file is part of Tuihai.
*
* Tuihai 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 / followback.php
Created June 10, 2020 22:51
自動フォローバックのソースコード。最悪な実装です。
<?php
/**
* Copyright (c) 2020 PJZ9n.
*
* This file is part of Tuihai.
*
* Tuihai 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
public function onDataPacketReceive(DataPacketReceiveEvent $event)
{
$packet = $event->getPacket();
if ($packet instanceof PlayerActionPacket) {
$name = $event->getPlayer()->getName();
switch ($packet->action) {
case PlayerActionPacket::ACTION_START_BREAK://破壊開始
$this->isBreaking[$name] = true;
break;