Skip to content

Instantly share code, notes, and snippets.

View TheNewHEROBRINEX's full-sized avatar

TheNewHEROBRINE TheNewHEROBRINEX

  • Italy
  • 10:28 (UTC +02:00)
View GitHub Profile
<?php
declare(strict_types=1);
/**
* @name NullComplexDataTest
* @author TheNewHEROBRINE
* @version 1.0.0
* @api 5.0.0
* @main TheNewHEROBRINE\NullComplexDataTest\Main
*/

Keybase proof

I hereby claim:

  • I am thenewherobrinex on github.
  • I am thenewherobrine (https://keybase.io/thenewherobrine) on keybase.
  • I have a public key ASB6iHDIRiDq7C30CYFTZ9PeRJqqKarry3DB6hRdQ6fgwgo

To claim this, I am signing this object:

@TheNewHEROBRINEX
TheNewHEROBRINEX / dynamicallyRegisterEventListeners.php
Last active March 28, 2021 08:29
Function to dynamically register event listeners in a PocketMine-MP plugin.
<?php
public function registerEventListeners() : void{
/** @var \SplFileInfo $file */
foreach(new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . DIRECTORY_SEPARATOR . 'listener')), '/^.+Listener\.php$/') as $file){
/** @phpstan-var class-string<ListenerBase> $classFullName */
$classFullName = str_replace(DIRECTORY_SEPARATOR, '\\', substr($file->getPath(), strlen($this->getFile() . 'src' . DIRECTORY_SEPARATOR))) . '\\' . $file->getBasename('.php');
$eventListenerClass = new ReflectionClass($classFullName);
if(!$eventListenerClass->isAbstract()){
/** @var ListenerBase $eventListenerInstance */
$eventListenerInstance = $eventListenerClass->newInstance($this);
@TheNewHEROBRINEX
TheNewHEROBRINEX / start.sh
Last active February 15, 2023 13:51
Start script for Paper based on the one of PocketMine-MP and which uses the JVM flags listed here
#!/usr/bin/env bash
FLAGS="-Xms256M -Xmx3584M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true $FLAGS"
DIR="$(cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
cd "$DIR"
while getopts "l" OPTION 2> /dev/null; do
case ${OPTION} in
l)
DO_LOOP="yes"
<?php
declare(strict_types = 1);
namespace EssentialsPE\Tasks;
use EssentialsPE\Loader;
use pocketmine\Player;
use pocketmine\scheduler\AsyncTask;
use pocketmine\Server;
<?php
declare(strict_types=1);
/**
* @name SetKeepXpTest
* @main TheNewHEROBRINE\SetKeepXpTest\SetKeepXpTest
* @api 4.0.0
* @version 1.0.0
* @author TheNewHEROBRINE
*/
<?php
public function onItemPickup(InventoryPickupItemEvent $event) : void{
$inventory = $event->getInventory();
if($inventory instanceof PlayerInventory){
$player = $inventory->getHolder();
if($player instanceof Player){
$murderPlayer = $this->plugin->findMurderPlayer($player);
$itemEntity = $event->getItem();
$itemItem = $itemEntity->getItem();
if($murderPlayer instanceof MurderPlayer){
function message {
echo "[*] $1"
}
message "PocketMine-MP sta per essere installato nella cartella corrente (`pwd`)"
read -p "Premi invio per iniziare l'installazione...
"
message "Download dei binari PHP..."
wget https://jenkins.pmmp.io/job/PHP-8.0-Linux-x86_64/lastSuccessfulBuild/artifact/PHP_Linux-x86_64.tar.gz
tar xzf PHP_Linux-x86_64.tar.gz
<?php
const WRAPPER = "\xfe\xfd";
const SESSIONID = "\x01\x02\x03\x04";
const HANDSHAKE = "\x09";
const STATISTICS = "\x00";
function queryPMMPServer(string $ip, int $port = 19132): array {
$socket = fsockopen("udp://" . gethostbyname($ip), $port, $errno, $errstr);
name: string
version: string
main: string
api: string[]|string
mcpe-protocol: int[]|int
commands:
string:
description: string
usage: string
aliases: string[]