Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

MineDeepRock/scoreboard_system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScoreboardSystem

スコアボードを簡単に実装できます

use文

use scoreboard_system\models\Scoreboard;
use scoreboard_system\models\Score;
use scoreboard_system\models\ScoreboardSlot;
use scoreboard_system\models\ScoreSortType;

sample

use scoreboard_system\models\Scoreboard;
use scoreboard_system\models\Score;
use scoreboard_system\models\ScoreboardSlot;
use scoreboard_system\models\ScoreSortType;
use pocketmine\Player;

class PlayerStatusScoreboard extends Scoreboard
{
    private static function create(string $name, int $money, int $level): Scoreboard {
        $slot = ScoreboardSlot::sideBar();
        $scores = [
            new Score($slot, "=========", 0, 0),
            new Score($slot, "Name:" . $name, 1, 1),
            new Score($slot, "Money:" . $money, 2, 2),
            new Score($slot, "Level:" . $level, 3, 3),
        ];
        return parent::__create($slot, "Server Name", $scores, ScoreSortType::smallToLarge());
    }

    static function send(Player $player, int $money, int $level) {
        $scoreboard = self::create($player->getName(), $money, $level);
        parent::__send($player, $scoreboard);
    }

    static function update(Player $player, int $money, int $level) {
        $scoreboard = self::create($player->getName(), $money, $level);
        parent::__update($player, $scoreboard);
    }
}
/***
$player = null;
$money = 1000;
$level = 5;
PlayerStatusScoreboard::send($player, $money, $level);
$money = 2000;
PlayerStatusScoreboard::update($player, $money, $level);

PlayerStatusScoreboard::addScore($player, "ようこそ", 4, 4);
PlayerStatusScoreboard::updateScore($player, "ようこそ○○サーバーへ", 4, 4);
PlayerStatusScoreboard::deleteScore($player, 4);
***/