Skip to content
This repository was archived by the owner on Feb 8, 2019. It is now read-only.

Commit 548edf0

Browse files
authored
Merge pull request #4 from VectorNetworkProject/develop
Release v0.0.5
2 parents cada851 + e37f4ba commit 548edf0

28 files changed

+708
-44
lines changed

.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.poggit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ branches:
55
projects:
66
TheMix:
77
path: ""
8+
libs:
9+
- src: fuyutsuki/libform/libform
10+
version: 0.4.0
811
...

.vscode/settings.json

Whitespace-only changes.

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,13 @@
1818
[![StyleCI](https://github.styleci.io/repos/157084851/shield?branch=master)](https://github.styleci.io/repos/157084851)
1919

2020
# The Mix
21-
Original game of VectorNetwork
21+
VectorNetworkの新しいゲームプラグイン!
22+
あなたは簡単な作業をするだけでゲームを遊ぶ事が出来る!
23+
24+
# DEVirion
25+
プラグインをスムーズに開発する為に[DEVirion](https://github.com/poggit/devirion)を使用しています。
26+
以下のライブラリを使用しています。
27+
28+
[libform](https://github.com/fuyutsuki/libform) - yuko fuyutsuki
29+
2230
</div>

plugin.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,3 @@ authors:
1313
- yuko fuyutsuki
1414
- DusKong
1515
- UramnOIL
16-
17-
permissions:
18-
the.mix.command.ping:
19-
default: true
20-
the.mix.command.tps:
21-
default: true

src/VectorNetworkProject/TheMix/TheMix.php

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,52 @@
1010

1111
use pocketmine\plugin\PluginBase;
1212
use pocketmine\utils\TextFormat;
13-
use VectorNetworkProject\TheMix\command\PingCommand;
14-
use VectorNetworkProject\TheMix\command\TpsCommand;
13+
use tokyo\pmmp\libform\FormApi;
14+
use VectorNetworkProject\TheMix\command\defaults\ModeratorCommand;
15+
use VectorNetworkProject\TheMix\command\defaults\PingCommand;
16+
use VectorNetworkProject\TheMix\command\defaults\TpsCommand;
17+
use VectorNetworkProject\TheMix\command\Permissions;
18+
use VectorNetworkProject\TheMix\event\TheBlockBreakEvent;
19+
use VectorNetworkProject\TheMix\event\TheBlockPlaceEvent;
1520
use VectorNetworkProject\TheMix\event\ThePlayerJoinEvent;
1621
use VectorNetworkProject\TheMix\event\ThePlayerLoginEvent;
1722
use VectorNetworkProject\TheMix\event\ThePlayerQuitEvent;
23+
use VectorNetworkProject\TheMix\game\DefaultConfig;
1824

1925
class TheMix extends PluginBase
2026
{
2127
/* @var TheMix $instance */
2228
private static $instance = null;
2329

30+
public const PLUGIN_CONFIG_VERSION = 1;
31+
2432
public function onLoad()
2533
{
2634
self::$instance = $this;
35+
DefaultConfig::init();
2736
$this->getLogger()->notice('Loading System...');
2837
}
2938

3039
public function onEnable()
3140
{
41+
Permissions::registerPermissions();
42+
FormApi::register($this);
3243
$this->registerCommands();
3344
$this->registerEvents();
45+
$this->getServer()->loadLevel(DefaultConfig::getStageLevelName())
46+
? $this->getLogger()->notice('Loaded stage.')
47+
: $this->getServer()->generateLevel(DefaultConfig::getStageLevelName());
3448
$this->getLogger()->notice(TextFormat::AQUA.'
3549
3650
37-
███ ▄█ █▄ ▄████████ ▄▄▄▄███▄▄▄▄ ▄█ ▀████ ▐████▀
38-
▀█████████▄ ███ ███ ███ ███ ▄██▀▀▀███▀▀▀██▄ ███ ███▌ ████▀
39-
▀███▀▀██ ███ ███ ███ █▀ ███ ███ ███ ███▌ ███ ▐███
40-
███ ▀ ▄███▄▄▄▄███▄▄ ▄███▄▄▄ ███ ███ ███ ███▌ ▀███▄███▀
41-
███ ▀▀███▀▀▀▀███▀ ▀▀███▀▀▀ ███ ███ ███ ███▌ ████▀██▄
42-
███ ███ ███ ███ █▄ ███ ███ ███ ███ ▐███ ▀███
43-
███ ███ ███ ███ ███ ███ ███ ███ ███ ▄███ ███▄
44-
▄████▀ ███ █▀ ██████████ ▀█ ███ █▀ █▀ ████ ███▄
51+
███ ▄█ █▄ ▄████████ ▄▄▄▄███▄▄▄▄ ▄█ ▀████ ▐████▀
52+
▀█████████▄ ███ ███ ███ ███ ▄██▀▀▀███▀▀▀██▄ ███ ███▌ ████▀
53+
▀███▀▀██ ███ ███ ███ █▀ ███ ███ ███ ███▌ ███ ▐███
54+
███ ▀ ▄███▄▄▄▄███▄▄ ▄███▄▄▄ ███ ███ ███ ███▌ ▀███▄███▀
55+
███ ▀▀███▀▀▀▀███▀ ▀▀███▀▀▀ ███ ███ ███ ███▌ ████▀██▄
56+
███ ███ ███ ███ █▄ ███ ███ ███ ███ ▐███ ▀███
57+
███ ███ ███ ███ ███ ███ ███ ███ ███ ▄███ ███▄
58+
▄████▀ ███ █▀ ██████████ ▀█ ███ █▀ █▀ ████ ███▄
4559
4660
4761
');
@@ -65,6 +79,7 @@ private function registerCommands(): void
6579
$commands = [
6680
new PingCommand($this),
6781
new TpsCommand($this),
82+
new ModeratorCommand($this),
6883
];
6984
$this->getServer()->getCommandMap()->registerAll($this->getName(), $commands);
7085
}
@@ -75,5 +90,7 @@ private function registerEvents(): void
7590
$plm->registerEvents(new ThePlayerLoginEvent(), $this);
7691
$plm->registerEvents(new ThePlayerJoinEvent(), $this);
7792
$plm->registerEvents(new ThePlayerQuitEvent(), $this);
93+
$plm->registerEvents(new TheBlockBreakEvent(), $this);
94+
$plm->registerEvents(new TheBlockPlaceEvent(), $this);
7895
}
7996
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2018 VectorNetworkProject. All rights reserved. MIT license.
4+
*
5+
* GitHub: https://github.com/VectorNetworkProject/TheMix
6+
* Website: https://www.vector-network.tk
7+
*/
8+
9+
namespace VectorNetworkProject\TheMix\command;
10+
11+
use pocketmine\permission\Permission;
12+
use pocketmine\permission\PermissionManager;
13+
14+
class Permissions
15+
{
16+
public const USER = 'the.mix.commands.user.';
17+
public const ADMIN = 'the.mix.commands.admin.';
18+
19+
public static function registerPermissions(): void
20+
{
21+
PermissionManager::getInstance()->addPermission(new Permission(self::USER.'ping', '応答速度を計測します。', Permission::DEFAULT_TRUE));
22+
PermissionManager::getInstance()->addPermission(new Permission(self::USER.'tps', 'TicksPerSecond', Permission::DEFAULT_TRUE));
23+
PermissionManager::getInstance()->addPermission(new Permission(self::ADMIN.'moderator', 'ModeratorTools', Permission::DEFAULT_OP));
24+
}
25+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2018 VectorNetworkProject. All rights reserved. MIT license.
4+
*
5+
* GitHub: https://github.com/VectorNetworkProject/TheMix
6+
* Website: https://www.vector-network.tk
7+
*/
8+
9+
namespace VectorNetworkProject\TheMix\command\defaults;
10+
11+
use pocketmine\command\CommandSender;
12+
use pocketmine\command\PluginCommand;
13+
use pocketmine\level\Position;
14+
use pocketmine\Player;
15+
use pocketmine\plugin\Plugin;
16+
use pocketmine\Server;
17+
use pocketmine\utils\TextFormat;
18+
use tokyo\pmmp\libform\element\Button;
19+
use tokyo\pmmp\libform\FormApi;
20+
use VectorNetworkProject\TheMix\command\Permissions;
21+
use VectorNetworkProject\TheMix\game\DefaultConfig;
22+
23+
class ModeratorCommand extends PluginCommand
24+
{
25+
/**
26+
* ModeratorCommand constructor.
27+
*
28+
* @param Plugin $owner
29+
*/
30+
public function __construct(Plugin $owner)
31+
{
32+
parent::__construct('moderator', $owner);
33+
$this->setDescription('モデレーター専用メニュー(管理権限持ちのユーザー以外使用不可能)');
34+
$this->setPermission(Permissions::ADMIN.'moderator');
35+
}
36+
37+
/**
38+
* @param CommandSender $sender
39+
* @param string $commandLabel
40+
* @param array $args
41+
*
42+
* @return bool|mixed
43+
*/
44+
public function execute(CommandSender $sender, string $commandLabel, array $args)
45+
{
46+
if (!$this->testPermission($sender)) {
47+
return true;
48+
}
49+
$sender instanceof Player
50+
? self::sendModeratorUI($sender)
51+
: $sender->sendMessage(TextFormat::RED.'プレイヤーのみ実行可能です。');
52+
53+
return true;
54+
}
55+
56+
public static function sendModeratorUI(Player $player): void
57+
{
58+
$form = FormApi::makeListForm(function (Player $player, ?int $data) {
59+
if (FormApi::formCancelled($data)) {
60+
return;
61+
}
62+
switch ($data) {
63+
case 0:
64+
self::sendLevelManagerUI($player);
65+
break;
66+
}
67+
});
68+
$form->setTitle('Moderator Menu');
69+
$form->setContent('行う処理を選んで下さい。');
70+
$form->addButton(new Button('テレポート'));
71+
$form->sendToPlayer($player);
72+
}
73+
74+
public static function sendLevelManagerUI(Player $player): void
75+
{
76+
$form = FormApi::makeListForm(function (Player $player, ?int $data) {
77+
if (FormApi::formCancelled($data)) {
78+
return;
79+
}
80+
switch ($data) {
81+
case 0:
82+
$player->teleport(Server::getInstance()->getDefaultLevel()->getSpawnLocation());
83+
break;
84+
case 1:
85+
$player->teleport(new Position(256, 5, 256, Server::getInstance()->getLevelByName(DefaultConfig::getStageLevelName())));
86+
break;
87+
case 2:
88+
self::sendModeratorUI($player);
89+
break;
90+
}
91+
});
92+
$form->setTitle('WorldManager');
93+
$form->setContent('テレポートするワールドを選択して下さい。');
94+
$form->addButton(new Button('lobby(default world)'));
95+
$form->addButton(new Button('Stage'));
96+
$form->addButton(new Button('戻る'));
97+
$form->sendToPlayer($player);
98+
}
99+
}

src/VectorNetworkProject/TheMix/command/PingCommand.php renamed to src/VectorNetworkProject/TheMix/command/defaults/PingCommand.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
* Website: https://www.vector-network.tk
77
*/
88

9-
namespace VectorNetworkProject\TheMix\command;
9+
namespace VectorNetworkProject\TheMix\command\defaults;
1010

1111
use pocketmine\command\CommandSender;
1212
use pocketmine\command\PluginCommand;
1313
use pocketmine\Player;
1414
use pocketmine\plugin\Plugin;
1515
use pocketmine\utils\TextFormat;
16+
use VectorNetworkProject\TheMix\command\Permissions;
1617

1718
class PingCommand extends PluginCommand
1819
{
@@ -25,17 +26,17 @@ public function __construct(Plugin $owner)
2526
{
2627
parent::__construct('ping', $owner);
2728
$this->setDescription('応答速度を計測します。');
28-
$this->setPermission('the.mix.command.ping');
29+
$this->setPermission(Permissions::USER.'ping');
2930
}
3031

3132
/**
3233
* @param CommandSender $sender
3334
* @param string $commandLabel
3435
* @param array $args
3536
*
36-
* @return bool
37+
* @return mixed
3738
*/
38-
public function execute(CommandSender $sender, string $commandLabel, array $args): bool
39+
public function execute(CommandSender $sender, string $commandLabel, array $args)
3940
{
4041
if (!$sender instanceof Player) {
4142
$sender->sendMessage(TextFormat::RED.'このコマンドはプレイヤーのみ実行可能です。');

src/VectorNetworkProject/TheMix/command/TpsCommand.php renamed to src/VectorNetworkProject/TheMix/command/defaults/TpsCommand.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
* Website: https://www.vector-network.tk
77
*/
88

9-
namespace VectorNetworkProject\TheMix\command;
9+
namespace VectorNetworkProject\TheMix\command\defaults;
1010

1111
use pocketmine\command\CommandSender;
1212
use pocketmine\command\PluginCommand;
1313
use pocketmine\plugin\Plugin;
1414
use pocketmine\Server;
1515
use pocketmine\utils\TextFormat;
16+
use VectorNetworkProject\TheMix\command\Permissions;
1617

1718
class TpsCommand extends PluginCommand
1819
{
@@ -24,7 +25,7 @@ class TpsCommand extends PluginCommand
2425
public function __construct(Plugin $owner)
2526
{
2627
parent::__construct('tps', $owner);
27-
$this->setPermission('the.mix.command.tps');
28+
$this->setPermission(Permissions::USER.'tps');
2829
$this->setDescription('TicksPerSecond');
2930
}
3031

@@ -33,9 +34,9 @@ public function __construct(Plugin $owner)
3334
* @param string $commandLabel
3435
* @param array $args
3536
*
36-
* @return bool
37+
* @return mixed
3738
*/
38-
public function execute(CommandSender $sender, string $commandLabel, array $args): bool
39+
public function execute(CommandSender $sender, string $commandLabel, array $args)
3940
{
4041
$sender->sendMessage(TextFormat::GREEN.'TPS: '.Server::getInstance()->getTicksPerSecond().'/20');
4142

0 commit comments

Comments
 (0)