Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Examples and tutorials can be found on the [RankSystem Wiki](https://github.com/
- Multi-rank inheritance system to allow you to inherit rank permissions
- Temp-ranks
- Temp-permissions
- PlaceholderAPI Support
- SQLite3 Provider Support
- MySQL Provider Support
- Easy Rank Creation / Edit System
Expand Down
6 changes: 6 additions & 0 deletions src/IvanCraft623/RankSystem/RankSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
use IvanCraft623\RankSystem\provider\Provider;
use IvanCraft623\RankSystem\provider\libasynql as libasynqlProvider;

use IvanCraft623\RankSystem\utils\PlaceholderUtils;
use JackMD\ConfigUpdater\ConfigUpdater;
use JackMD\UpdateNotifier\UpdateNotifier;

use MohamadRZ4\Placeholder\PlaceholderAPI;
use pocketmine\permission\PermissionManager;
use pocketmine\permission\DefaultPermissions;
use pocketmine\plugin\DisablePluginException;
Expand Down Expand Up @@ -81,6 +83,10 @@ public function onEnable() : void {
PacketHooker::register($this);
}

if ($this->getServer()->getPluginManager()->getPlugin("PlaceholderAPI") !== null) {
PlaceholderAPI::getInstance()->registerExpansion(new PlaceholderUtils($this));
}

$this->loadCommands();
$this->loadListeners();
$this->loadProvider();
Expand Down
57 changes: 57 additions & 0 deletions src/IvanCraft623/RankSystem/utils/PlaceholderUtils.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace IvanCraft623\RankSystem\utils;

use IvanCraft623\RankSystem\RankSystem;
use IvanCraft623\RankSystem\session\SessionManager;
use MohamadRZ4\Placeholder\expansion\PlaceholderExpansion;
use pocketmine\player\Player;

class PlaceholderUtils extends PlaceholderExpansion
{

private RankSystem $rankSystem;

public function __construct(RankSystem $rankSystem)
{
$this->rankSystem = $rankSystem;
}

public function getIdentifier(): string
{
return "RankSystem";
}

public function getAuthor(): string
{
return "IvanCraft623";
}

public function getVersion(): string
{
return "1.0.0";
}


public function onPlaceholderRequest(?Player $player, string $params): ?string
{
if ($player === null) return null;

$ranksystem = $this->rankSystem;
$sessionmanager = $ranksystem->getSessionManager();

$session = $sessionmanager->get("IvanCraft236");
if ($session === null) return null;

switch ($params) {
case "ranks":
return implode(", ", $session->getRanks());
case "highest_rank":
return $session->getHighestRank()->getName();
case "nametag":
return $session->getNameTagFormat();
default:
return null;
}
}
}