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

Commit 247465a

Browse files
committed
Merge branch 'release/0.0.2'
2 parents 1220e45 + 1f8a1a6 commit 247465a

File tree

11 files changed

+174
-116
lines changed

11 files changed

+174
-116
lines changed

plugin.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
name: TheMix
22
main: VectorNetworkProject\TheMix\TheMix
33
api: 3.0.0
4-
prefix: TheMix
4+
softdepend:
5+
- ScoreboardsPE
56

67
description: "Original game of VectorNetwork"
78
website: "https://vector-network.tk"
8-
version: 0.0.1
9+
version: 0.0.2
910
authors:
1011
- InkoHX
1112
- MazaiCrafty

src/VectorNetworkProject/TheMix/DataBase.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/VectorNetworkProject/TheMix/TheMix.php

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
use pocketmine\plugin\PluginBase;
1313
use pocketmine\utils\TextFormat;
1414
use VectorNetworkProject\TheMix\command\PingCommand;
15+
use VectorNetworkProject\TheMix\command\TpsCommand;
16+
use VectorNetworkProject\TheMix\event\ThePlayerJoinEvent;
17+
use VectorNetworkProject\TheMix\event\ThePlayerLoginEvent;
18+
use VectorNetworkProject\TheMix\event\ThePlayerQuitEvent;
1519

1620
class TheMix extends PluginBase
1721
{
@@ -27,16 +31,21 @@ public function onLoad()
2731
public function onEnable()
2832
{
2933
$this->registerCommands();
30-
$this->getLogger()->notice(TextFormat::GREEN . "
34+
$this->registerEvents();
35+
$this->getLogger()->notice(TextFormat::AQUA . '
3136
32-
████████╗██╗ ██╗███████╗ ███╗ ███╗██╗██╗ ██╗
33-
╚══██╔══╝██║ ██║██╔════╝ ████╗ ████║██║╚██╗██╔╝
34-
██║ ███████║█████╗ ██╔████╔██║██║ ╚███╔╝
35-
██║ ██╔══██║██╔══╝ ██║╚██╔╝██║██║ ██╔██╗
36-
██║ ██║ ██║███████╗ ██║ ╚═╝ ██║██║██╔╝ ██╗
37-
╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═╝
3837
39-
");
38+
███ ▄█ █▄ ▄████████ ▄▄▄▄███▄▄▄▄ ▄█ ▀████ ▐████▀
39+
▀█████████▄ ███ ███ ███ ███ ▄██▀▀▀███▀▀▀██▄ ███ ███▌ ████▀
40+
▀███▀▀██ ███ ███ ███ █▀ ███ ███ ███ ███▌ ███ ▐███
41+
███ ▀ ▄███▄▄▄▄███▄▄ ▄███▄▄▄ ███ ███ ███ ███▌ ▀███▄███▀
42+
███ ▀▀███▀▀▀▀███▀ ▀▀███▀▀▀ ███ ███ ███ ███▌ ████▀██▄
43+
███ ███ ███ ███ █▄ ███ ███ ███ ███ ▐███ ▀███
44+
███ ███ ███ ███ ███ ███ ███ ███ ███ ▄███ ███▄
45+
▄████▀ ███ █▀ ██████████ ▀█ ███ █▀ █▀ ████ ███▄
46+
47+
48+
');
4049
}
4150

4251
public function onDisable()
@@ -52,19 +61,20 @@ public static function getInstance(): TheMix
5261
return self::$instance;
5362
}
5463

55-
/**
56-
* @return DataBase
57-
*/
58-
public static function getDataBase(): DataBase
59-
{
60-
return new DataBase();
61-
}
62-
6364
private function registerCommands(): void
6465
{
6566
$commands = [
66-
new PingCommand($this)
67+
new PingCommand($this),
68+
new TpsCommand($this)
6769
];
6870
$this->getServer()->getCommandMap()->registerAll($this->getName(), $commands);
6971
}
72+
73+
private function registerEvents(): void
74+
{
75+
$plm = $this->getServer()->getPluginManager();
76+
$plm->registerEvents(new ThePlayerLoginEvent(), $this);
77+
$plm->registerEvents(new ThePlayerJoinEvent(), $this);
78+
$plm->registerEvents(new ThePlayerQuitEvent(), $this);
79+
}
7080
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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\event;
10+
11+
12+
use pocketmine\event\Listener;
13+
use pocketmine\event\player\PlayerJoinEvent;
14+
use Miste\scoreboardspe\API\{
15+
Scoreboard, ScoreboardDisplaySlot, ScoreboardSort, ScoreboardAction
16+
};
17+
use VectorNetworkProject\TheMix\task\UpdateScoreboardTask;
18+
use VectorNetworkProject\TheMix\TheMix;
19+
20+
class ThePlayerJoinEvent implements Listener
21+
{
22+
public function event(PlayerJoinEvent $event)
23+
{
24+
$player = $event->getPlayer();
25+
$scoreboard = new Scoreboard(TheMix::getInstance()->getServer()->getPluginManager()->getPlugin("ScoreboardsPE")->getPlugin(), "§l§7=== §6THE §aM§cI§eX §7===", ScoreboardAction::CREATE);
26+
$scoreboard->create(ScoreboardDisplaySlot::SIDEBAR, ScoreboardSort::DESCENDING);
27+
$scoreboard->addDisplay($player);
28+
TheMix::getInstance()->getScheduler()->scheduleRepeatingTask(new UpdateScoreboardTask($scoreboard, $player), 20);
29+
}
30+
}
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\event;
10+
11+
12+
use pocketmine\event\Listener;
13+
use pocketmine\event\player\PlayerLoginEvent;
14+
use VectorNetworkProject\TheMix\provider\DataFile;
15+
use VectorNetworkProject\TheMix\provider\JSON;
16+
17+
class ThePlayerLoginEvent implements Listener
18+
{
19+
public function event(PlayerLoginEvent $event)
20+
{
21+
$player = $event->getPlayer();
22+
$db = new JSON($player->getXuid(), DataFile::PLAYER_LEVEL);
23+
$db->init();
24+
}
25+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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\event;
10+
11+
12+
use pocketmine\event\Listener;
13+
use pocketmine\event\player\PlayerQuitEvent;
14+
15+
class ThePlayerQuitEvent implements Listener
16+
{
17+
public function event(PlayerQuitEvent $event)
18+
{
19+
$player = $event->getPlayer();
20+
}
21+
}

src/VectorNetworkProject/TheMix/lib/database/Provider.php

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,61 +13,6 @@
1313

1414
abstract class Provider
1515
{
16-
public function createTable()
17-
{
18-
throw new \Error("Missing method 'createTable'");
19-
}
20-
21-
public function deleteTable()
22-
{
23-
throw new \Error("Missing method 'deleteTable'");
24-
}
25-
26-
public function hasTable()
27-
{
28-
throw new \Error("Missing method 'hasTable'");
29-
}
30-
31-
public function create()
32-
{
33-
throw new \Error("Missing method 'create'");
34-
}
35-
36-
public function delete()
37-
{
38-
throw new \Error("Missing method 'delete'");
39-
}
40-
41-
public function has()
42-
{
43-
throw new \Error("Missing method 'has'");
44-
}
45-
46-
public function set()
47-
{
48-
throw new \Error("Missing method 'set'");
49-
}
50-
51-
public function remove()
52-
{
53-
throw new \Error("Missing method 'remove'");
54-
}
55-
56-
public function get()
57-
{
58-
throw new \Error("Missing method 'get'");
59-
}
60-
61-
public function getAll()
62-
{
63-
throw new \Error("Missing method 'getAll'");
64-
}
65-
66-
public function getKeys()
67-
{
68-
throw new \Error("Missing method 'getKeys'");
69-
}
70-
7116
protected static function getPath(string $folder, string $type): string
7217
{
7318
return TheMix::getInstance()->getDataFolder() . '/' . $folder . '/' . $type . '/';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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\provider;
10+
11+
12+
interface DataFile
13+
{
14+
public const PLAYER_LEVEL = 'Level';
15+
}

src/VectorNetworkProject/TheMix/provider/JSON.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111

1212
use pocketmine\utils\Config;
13+
use pocketmine\utils\MainLogger;
1314
use VectorNetworkProject\TheMix\lib\database\Provider;
1415

1516
class JSON extends Provider
@@ -31,15 +32,21 @@ public function __construct(string $xuid, string $file)
3132
$this->file = $file . '.json';
3233
}
3334

35+
public function init(array $data = []): void
36+
{
37+
if (!$this->hasTable()) $this->createTable($data);
38+
}
39+
3440
/**
3541
* @param array $table
3642
* @return void
3743
*/
3844
public function createTable(array $table = []): void
3945
{
40-
@mkdir($this->path);
46+
@mkdir($this->path, 0755, true);
4147
$config = new Config($this->path . $this->file, Config::JSON, $table);
4248
$config->save();
49+
MainLogger::getLogger()->debug("[PROVIDER] Create ".$this->file);
4350
}
4451

4552
/**
@@ -53,13 +60,11 @@ public function hasTable(): bool
5360
}
5461

5562
/**
56-
* @return bool
63+
* @return void
5764
*/
58-
public function deleteTable(): bool
65+
public function deleteTable(): void
5966
{
60-
return unlink($this->path . $this->file)
61-
? true
62-
: false;
67+
unlink($this->path . $this->file);
6368
}
6469

6570
/**
@@ -105,7 +110,7 @@ public function getKeys(): array
105110
* @param string $key
106111
* @return bool
107112
*/
108-
public function has(string $key): bool
113+
public function exists(string $key): bool
109114
{
110115
$config = new Config($this->path . $this->file, Config::JSON);
111116
return $config->exists($key)

src/VectorNetworkProject/TheMix/provider/YAML.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function getKeys(): array
104104
* @param string $key
105105
* @return bool
106106
*/
107-
public function has(string $key): bool
107+
public function exists(string $key): bool
108108
{
109109
$config = new Config($this->path . $this->file, Config::YAML);
110110
return $config->exists($key)

0 commit comments

Comments
 (0)