EPT8TPE / Prisons

A pocketmine plugin implementing the legacy prison rank up system in addition to a form of prestiging.
MIT License
9 stars 3 forks source link

Prisons

A pocketmine plugin implementing the legacy prison rank up system in addition to a form of prestiging.

How to install

  1. Download the phar here.
  2. Add it to your servers 'plugins' directory.
  3. Restart your server.

Features

Commands

- /prestige - Reset your rank and multiply your rank up price by a specified amount.
- /rankup - Rank up to the next rank.

Permissions

prisons.*:
    default: op
    description: Allows access to all prison commands.
    children:
      prisons.rankup:
        default: true
        description: Allows user to use /rankup.
      prisons.prestige:
        default: true
        description: Allows players to use /prestige.
      prisons.nomine.bypass:
        default: op
        description: Allows players to mine/place blocks in areas that are not mine areas.  

Addons/Dependencies

API

Here's an example of me getting and setting the prestige and rank of a player.

<?php

declare(strict_types = 1);

namespace TPE\Test;

use TPE\Prisons\Prisons;
use pocketmine\Player;
use TPE\Prisons\PrisonPlayer;

class TestPlugin extends PluginBase {

    public function onEnable() {
        // enabled
    }

    public function getPrisonPlayer(Player $player) : ?PrisonPlayer {
        return Prisons::get()->getPlayerManager()->getPlayer($player) ?? null;
    }

    public function getPrisonRank(PrisonPlayer $player) : ?string {
        return $player->getPrisonRank() ?? null;
        // returns the prison rank of a player e.g 'a'.
    }

    public function setPrisonRank(PrisonPlayer $player, string $rank) : void {
        $player->setPrisonRank($rank);
        // sets the prison rank to whatever '$rank' is 
    }

    public function getPrestige(PrisonPlayer $player) : ?int {
        return $player->getPrestige() ?? null;
        // returns the prestige of a player, by default this is 0.
    }

    public function setPrestige(PrisonPlayer $player, int $prestige) : void {
        $player->setPrestige($prestige);
        // sets a players prestige to whatever '$prestige' is.
    }
}

Keep in mind that none of those functions are implemented into this plugin, you create them yourself.

declare(strict_types = 1);

namespace TPE\Test;

use pocketmine\event\Listener; use TPE\Prisons\Listener\PrisonListener\PrisonRankUpEvent; use TPE\Prisons\Listener\PrisonListener\PrisonPrestigeEvent;

class EventListener implements Listener {

public function onRankUp(PrisonRankUpEvent $event) : void {
    $player = $event->getPlayer(); // returns a 'Player' instance, not a 'PrisonPlayer' instance.
    $currentRank = $event->getCurrentRank(); // returns a string representing the current rank of a player.
    $newRank = $event->getNewRank(); // returns a string representing what the players rank will be set to when the event executes.
    $addedperms = $event->getAddedPermissions(); // returns a string array representing all added permissions for the specific rankup.
    $removedperms = $event->getRemovedPermissions(); // returns a string array representing all removed permissions for the specific rankup.
    $commands = $event->getCommands(); // returns a string array of all commands ran during rankup.

    $event->setAddedPermissions(["prisons.*"]); // sets the added permissions for that specific players rankup to 'prisons.*', you can specify multiple.
    $event->setRemovedPermissions(["prisons.prestige"]); // sets the removed permissions for that specific players rankup to 'prisons.prestige'.
    $event->setCommands(["say {PLAYER} has ranked up to {$newRank!"}]); // within all commands use {PLAYER} to represent the player in the event.
}

public function onPrestige(PrisonPrestigeEvent $event) {
    $player = $event->getPlayer(); // returns a 'Player' instance, not a 'PrisonPlayer' instance.
    $currentPrestige = $event->getCurrentPrestige; // returns an int representing the current prestige of a player.
    $newPrestige = $event->getNewPrestige(); // returns an int representing what the players prestige will be set to when the event executes.
    $addedperms = $event->getAddedPermissions(); // returns a string array representing all added permissions for the specific prestige.
    $removedperms = $event->getRemovedPermissions(); // returns a string array representing all removed permissions for the specific prestige.
    $commands = $event->getCommands(); // returns a string array of all commands ran during prestige.

    $event->setAddedPermissions(["prisons.*"]); // sets the added permissions for that specific players prestige to 'prisons.*', you can specify multiple.
    $event->setRemovedPermissions(["prisons.prestige"]); // sets the removed permissions for that specific players prestige to 'prisons.prestige'.
    $event->setCommands(["say {PLAYER} has prestiged to {$newPrestige!"}]); // within all commands use {PLAYER} to represent the player in the event.
} 

}



# Support
Contact me on discord ```TPE#1061``` if you have any further queries related to this plugin.