-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 11a2953
Showing
17 changed files
with
777 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Startup | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download PHP Release | ||
uses: dsaltares/fetch-gh-release-asset@1.1.0 | ||
with: | ||
file: PHP-Linux-x86_64-PM5.tar.gz | ||
repo: NetherGamesMC/php-build-scripts | ||
version: "tags/php-8.2-latest" | ||
|
||
- name: Unpack PHP Release | ||
run: tar -xzvf PHP-Linux-x86_64-PM5.tar.gz | ||
|
||
- name: Download Composer | ||
run: curl -o composer.phar "https://getcomposer.org/composer-stable.phar" | ||
|
||
- name: Config Composer | ||
run: ./bin/php7/bin/php composer.phar config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install Composer dependencies | ||
run: ./bin/php7/bin/php composer.phar install --prefer-dist --no-interaction | ||
|
||
- name: Run Build | ||
run: ./bin/php7/bin/php -dphar.readonly=0 vendor/bin/pharynx -i . -c -p=GlassBridge.phar | ||
|
||
- name: Get plugin.yml information | ||
run: | | ||
name=$(grep -oP '(?<=name: ).*' plugin.yml || echo "unknown") | ||
version=$(grep -oP '(?<=version: ).*' plugin.yml || echo "unknown") | ||
echo "Name of plugin: $name" | ||
echo "Version of plugin: $version" | ||
echo "PLUGIN_NAME=$name" >> $GITHUB_ENV | ||
echo "PLUGIN_VERSION=$version" >> $GITHUB_ENV | ||
- name: Create Release | ||
uses: ncipollo/release-action@v1.14.0 | ||
with: | ||
artifacts: ${{ github.workspace }}/Snow.phar | ||
draft: false | ||
name: ${{ env.PLUGIN_NAME }} v${{ env.PLUGIN_VERSION }} Release | ||
tag: v${{ env.PLUGIN_VERSION }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
body: "The artifacts are kept up to date with the master branch" | ||
commit: ${{ github.sha }} | ||
allowUpdates: true | ||
removeArtifacts: true | ||
replacesArtifacts: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: PHPStan CI | ||
|
||
on: push | ||
|
||
jobs: | ||
phpstan: | ||
name: PHPStan Analysis | ||
runs-on: ubuntu-latest | ||
if: "!contains(github.event.head_commit.message, '[ci skip]')" | ||
|
||
steps: | ||
- name: Startup | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download PHP Release | ||
uses: dsaltares/fetch-gh-release-asset@1.1.0 | ||
with: | ||
file: PHP-Linux-x86_64-PM5.tar.gz | ||
repo: NetherGamesMC/php-build-scripts | ||
version: "tags/php-8.2-latest" | ||
|
||
- name: Unpack PHP Release | ||
run: tar -xzvf PHP-Linux-x86_64-PM5.tar.gz | ||
|
||
- name: Download Composer | ||
run: curl -o composer.phar "https://getcomposer.org/composer-stable.phar" | ||
|
||
- name: Config Composer | ||
run: ./bin/php7/bin/php composer.phar config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install Composer dependencies | ||
run: ./bin/php7/bin/php composer.phar install --prefer-dist --no-interaction | ||
|
||
- name: Run PHPStan | ||
run: ./bin/php7/bin/php vendor/bin/phpstan.phar analyze --no-progress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/vendor/ | ||
/.idea | ||
/composer.lock | ||
/*.phar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "josscoder/glass-bridge", | ||
"type": "pocketmine-plugin", | ||
"autoload": { | ||
"classmap": [ | ||
"src/" | ||
] | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Josscoder", | ||
"email": "josscoder@hotmail.com" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"require": { | ||
"blockbrawn/commando": "dev-master" | ||
}, | ||
"require-dev": { | ||
"nethergamesmc/pocketmine-mp": "dev-stable", | ||
"sof3/pharynx": "dev-master", | ||
"phpstan/phpstan": "1.12.7" | ||
}, | ||
"repositories": [ | ||
{ | ||
"type": "vcs", | ||
"url": "git@github.com:NetherGamesMC/PocketMine-MP.git" | ||
} | ||
], | ||
"scripts": { | ||
"lint": [ | ||
"./vendor/bin/phpstan analyse --no-progress" | ||
], | ||
"build": [ | ||
"@php -dphar.readonly=0 ./vendor/bin/pharynx -i . -c -p=GlassBridge.phar" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
parameters: | ||
level: 9 | ||
paths: | ||
- src/GlassBridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: GlassBridge | ||
main: GlassBridge\GlassBridgePlugin | ||
authors: | ||
- Josscoder | ||
version: 1.0.0-ALPHA | ||
api: 5.17.0 | ||
|
||
permissions: | ||
glassbridge.command: | ||
default: op |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace GlassBridge; | ||
|
||
use CortexPE\Commando\exception\HookAlreadyRegistered; | ||
use CortexPE\Commando\PacketHooker; | ||
use GlassBridge\command\GlassBridgeCommand; | ||
use GlassBridge\listener\GlassBridgeListener; | ||
use GlassBridge\listener\GlassEditListener; | ||
use pocketmine\plugin\PluginBase; | ||
use pocketmine\utils\SingletonTrait; | ||
use pocketmine\utils\TextFormat; | ||
|
||
class GlassBridgePlugin extends PluginBase | ||
{ | ||
use SingletonTrait { | ||
setInstance as private; | ||
reset as private; | ||
} | ||
|
||
protected function onLoad(): void | ||
{ | ||
self::setInstance($this); | ||
} | ||
|
||
/** | ||
* @throws HookAlreadyRegistered | ||
*/ | ||
protected function onEnable(): void | ||
{ | ||
if (!PacketHooker::isRegistered()) { | ||
PacketHooker::register($this); | ||
} | ||
|
||
$pluginManager = $this->getServer()->getPluginManager(); | ||
$pluginManager->registerEvents(new GlassBridgeListener(), $this); | ||
$pluginManager->registerEvents(new GlassEditListener(), $this); | ||
|
||
$this->getServer()->getCommandMap()->register('glassbridge', new GlassBridgeCommand($this, 'glassbridge')); | ||
|
||
$this->getLogger()->info(TextFormat::GREEN . 'SquidGame Glass Bridge plugin enabled'); | ||
} | ||
|
||
protected function onDisable(): void | ||
{ | ||
$this->getLogger()->info(TextFormat::RED . 'SquidGame Glass Bridge plugin disabled'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace GlassBridge\command; | ||
|
||
use CortexPE\Commando\BaseCommand; | ||
use GlassBridge\command\subcommands\AddGlassSectionSubCommand; | ||
use GlassBridge\command\subcommands\EditGlassSectionSubCommand; | ||
use GlassBridge\command\subcommands\RemoveGlassSectionSubCommand; | ||
use GlassBridge\GlassBridgePlugin; | ||
use pocketmine\command\CommandSender; | ||
use pocketmine\plugin\Plugin; | ||
|
||
class GlassBridgeCommand extends BaseCommand | ||
{ | ||
/** | ||
* @var GlassBridgePlugin | ||
*/ | ||
protected Plugin $plugin; | ||
|
||
protected function prepare(): void | ||
{ | ||
$this->registerSubCommand(new AddGlassSectionSubCommand($this->plugin, | ||
'add', | ||
'Adds a new section of glass' | ||
)); | ||
$this->registerSubCommand(new RemoveGlassSectionSubCommand($this->plugin, | ||
'remove', | ||
'Removes a section of glass' | ||
)); | ||
$this->registerSubCommand(new EditGlassSectionSubCommand($this->plugin, | ||
'edit', | ||
'Edit a section of glass' | ||
)); | ||
|
||
$this->setPermission('glassbridge.command'); | ||
} | ||
|
||
/** | ||
* @param CommandSender $sender | ||
* @param string $aliasUsed | ||
* @param array<string, mixed> $args | ||
* @return void | ||
*/ | ||
public function onRun(CommandSender $sender, string $aliasUsed, array $args): void {} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/GlassBridge/command/subcommands/AddGlassSectionSubCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace GlassBridge\command\subcommands; | ||
|
||
use CortexPE\Commando\args\IntegerArgument; | ||
use CortexPE\Commando\BaseSubCommand; | ||
use CortexPE\Commando\constraint\InGameRequiredConstraint; | ||
use CortexPE\Commando\exception\ArgumentOrderException; | ||
use GlassBridge\data\GlassBridge; | ||
use GlassBridge\data\GlassSection; | ||
use pocketmine\command\CommandSender; | ||
use pocketmine\player\Player; | ||
use pocketmine\utils\TextFormat; | ||
|
||
class AddGlassSectionSubCommand extends BaseSubCommand | ||
{ | ||
/** | ||
* @throws ArgumentOrderException | ||
*/ | ||
protected function prepare(): void | ||
{ | ||
$this->registerArgument(0, new IntegerArgument('index')); | ||
$this->addConstraint(new InGameRequiredConstraint($this)); | ||
$this->setUsage('/glassbridge add <index>'); | ||
} | ||
|
||
/** | ||
* @param Player $sender | ||
* @param string $aliasUsed | ||
* @param array<string, mixed> $args | ||
* @return void | ||
*/ | ||
public function onRun(CommandSender $sender, string $aliasUsed, array $args): void | ||
{ | ||
/** @var int $index */ | ||
$index = $args['index']; | ||
|
||
if (GlassBridge::getInstance()->exists($index)) { | ||
$sender->sendMessage(TextFormat::RED . 'That section of the glass bridge already exists!'); | ||
|
||
return; | ||
} | ||
|
||
GlassBridge::getInstance()->addSection(new GlassSection($index, null, null)); | ||
|
||
$sender->sendMessage(TextFormat::colorize("&aYou have created the glass bridge section &e#$index&a!")); | ||
$sender->sendMessage(TextFormat::colorize("&bNow use &6/glassbridge edit <index> &bto set the &6firstGlass &band the &6secondGlass")); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/GlassBridge/command/subcommands/EditGlassSectionSubCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace GlassBridge\command\subcommands; | ||
|
||
use CortexPE\Commando\args\IntegerArgument; | ||
use CortexPE\Commando\BaseSubCommand; | ||
use CortexPE\Commando\constraint\InGameRequiredConstraint; | ||
use CortexPE\Commando\exception\ArgumentOrderException; | ||
use GlassBridge\data\GlassBridge; | ||
use GlassBridge\data\GlassSection; | ||
use GlassBridge\registry\GlassEditManager; | ||
use pocketmine\command\CommandSender; | ||
use pocketmine\player\Player; | ||
use pocketmine\utils\TextFormat; | ||
|
||
class EditGlassSectionSubCommand extends BaseSubCommand | ||
{ | ||
/** | ||
* @throws ArgumentOrderException | ||
*/ | ||
protected function prepare(): void | ||
{ | ||
$this->registerArgument(0, new IntegerArgument('index')); | ||
$this->addConstraint(new InGameRequiredConstraint($this)); | ||
$this->setUsage('/glassbridge edit <index>'); | ||
} | ||
|
||
/** | ||
* @param Player $sender | ||
* @param string $aliasUsed | ||
* @param array<string, mixed> $args | ||
* @return void | ||
*/ | ||
public function onRun(CommandSender $sender, string $aliasUsed, array $args): void | ||
{ | ||
/** @var int $index */ | ||
$index = $args['index']; | ||
|
||
if (is_null($glassSection = GlassBridge::getInstance()->getSection($index))) { | ||
$sender->sendMessage(TextFormat::RED . 'That section of the glass bridge does not exist!'); | ||
|
||
return; | ||
} | ||
|
||
if (GlassEditManager::getInstance()->exists($sender)) { | ||
$sender->sendMessage(TextFormat::RED . 'You are already editing another glass section, finish editing to edit another one!'); | ||
|
||
return; | ||
} | ||
|
||
$glassSection->setFirstGlass(null); | ||
$glassSection->setSecondGlass(null); | ||
|
||
GlassEditManager::getInstance()->addEditor($sender, $glassSection); | ||
$sender->sendMessage(TextFormat::colorize("&aYou are editing the glass section &e#$index&a!")); | ||
$sender->sendMessage(TextFormat::GOLD . "-> break the first glass's minVector"); | ||
} | ||
} |
Oops, something went wrong.