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 / pmmp-compatible-check-remove.php
Created September 17, 2020 12:29
API/プロトコルバージョンチェック無効化
<?php
declare(strict_types=1);
echo "-- PocketMineSourceInstaller --" . PHP_EOL;
echo "comment out" . PHP_EOL;
//フォルダ入力
folder:
echo "folder: ";
@PJZ9n
PJZ9n / pmmp-installer.php
Created September 17, 2020 12:21
PocketMine-MPのインストーラー(ソースコードで)
<?php
declare(strict_types=1);
echo "-- PocketMineSourceInstaller --" . PHP_EOL;
echo "install" . PHP_EOL;
//バージョン入力
version:
echo "version: ";
<?php
public function onPlayerJoin(PlayerJoinEvent $event): void
{
$player = $event->getPlayer();
$level = $this->getServer()->getDefaultLevel();
$chunkZ = 0;
$createCount = 0;
$failedCount = 0;
$this->getScheduler()->scheduleDelayedRepeatingTask(new ClosureTask(function (int $currentTick) use ($level, $player, &$chunkZ, &$createCount, &$failedCount) : void {
for ($i = 0; $i < 10; $i++) {
@PJZ9n
PJZ9n / glob.php
Created August 9, 2020 02:17
glob用
<?php
mb_substr($this->currentDirectory, -1, 1) !== "/" ? "/*" : "*";
@PJZ9n
PJZ9n / validateitemid.php
Created August 7, 2020 18:47
有効なアイテムIDがチェックする
<?php
/**
* @param int $id
*
* @throws InvalidArgumentException
*/
public static function validateItemId(int $id): void
{
if ($id < -0x8000 or $id > 0x7fff) { //signed short range
@PJZ9n
PJZ9n / search.php
Created August 7, 2020 17:16
捨てるの勿体ない気がするから
<?php
/**
* @param int $type
* @param int $itemId
* @param int $itemDamage
*
* @return ShopItem|null
*/
public function searchShopItem(int $type, int $itemId, int $itemDamage): ?ShopItem
{
<?php
/**
* Copyright (c) 2020 PJZ9n.
*
* This file is part of NewChestShop.
*
* NewChestShop 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 PJZ9n.
*
* This file is part of NewChestShop.
*
* NewChestShop 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 onPlayerChestInventoryChange(PlayerChestInventoryChangeEvent $event): void
{
$source = $event->getSource();
$target = $event->getTarget();
$player = $event->getPlayerCursorInventory()->getHolder();
//$player->removeWindow($event->getChestInventory());
/*$form = new class implements Form {
public function handleResponse(Player $player, $data): void
{
@PJZ9n
PJZ9n / JoinMessage.php
Created August 4, 2020 12:56
JoinMessage
<?php
declare(strict_types=1);
namespace pjz9n\joinmessage;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\plugin\PluginBase;
use pocketmine\utils\Config;