This repository was archived by the owner on Feb 8, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
src/VectorNetworkProject/TheMix Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414use VectorNetworkProject \TheMix \command \PingCommand ;
1515use VectorNetworkProject \TheMix \command \TpsCommand ;
1616use VectorNetworkProject \TheMix \event \ThePlayerLoginEvent ;
17+ use VectorNetworkProject \TheMix \task \UpdateScoreboardTask ;
1718
1819class TheMix extends PluginBase
1920{
@@ -30,6 +31,7 @@ public function onEnable()
3031 {
3132 $ this ->registerCommands ();
3233 $ this ->registerEvents ();
34+ $ this ->getScheduler ()->scheduleRepeatingTask (new UpdateScoreboardTask (), 20 );
3335 $ this ->getLogger ()->notice (TextFormat::AQUA . '
3436
3537
Original file line number Diff line number Diff line change 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 VectorNetworkProject \TheMix \lib \scoreboard \Scoreboard ;
15+
16+ class ThePlayerJoinEvent implements Listener
17+ {
18+ public function event (PlayerJoinEvent $ event )
19+ {
20+ $ player = $ event ->getPlayer ();
21+ Scoreboard::addBoard ($ player );
22+ }
23+ }
Original file line number Diff line number Diff line change 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+ use VectorNetworkProject \TheMix \lib \scoreboard \Scoreboard ;
15+
16+ class ThePlayerQuitEvent implements Listener
17+ {
18+ public function event (PlayerQuitEvent $ event )
19+ {
20+ $ player = $ event ->getPlayer ();
21+ Scoreboard::removeBoard ($ player );
22+ }
23+ }
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ public static function hasBoard(Player $player): bool
5353 */
5454 public static function setLine (Player $ player , int $ line , string $ text ): void
5555 {
56- if (!isset ( self ::$ scoreboards [ $ player-> getName ()] )) return ;
56+ if (!self ::hasBoard ( $ player )) return ;
5757 if ($ line < 1 || $ line > 15 ) return ;
5858 $ entry = new ScorePacketEntry ();
5959 $ entry ->objectiveName = "objective " ;
@@ -75,6 +75,6 @@ public static function removeBoard(Player $player): void
7575 $ packet = new RemoveObjectivePacket ();
7676 $ packet ->objectiveName = "objective " ;
7777 $ player ->sendDataPacket ($ packet );
78- if (isset ( self ::$ scoreboards [ ($ player-> getName ())] )) unset(self ::$ scoreboards [$ player ->getName ()]);
78+ if (self ::hasBoard ($ player )) unset(self ::$ scoreboards [$ player ->getName ()]);
7979 }
8080}
Original file line number Diff line number Diff line change 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 \task ;
10+
11+
12+ use pocketmine \scheduler \Task ;
13+ use pocketmine \Server ;
14+ use VectorNetworkProject \TheMix \lib \scoreboard \Scoreboard ;
15+
16+ class UpdateScoreboardTask extends Task
17+ {
18+ public function onRun (int $ currentTick )
19+ {
20+ foreach (Server::getInstance ()->getOnlinePlayers () as $ player ) {
21+ Scoreboard::setLine ($ player , 1 , 'test ' );
22+ Scoreboard::setLine ($ player , 2 , ' ' );
23+ Scoreboard::setLine ($ player , 3 , 'test ' );
24+ }
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments