Skip to content
This repository has been archived by the owner on Jan 23, 2022. It is now read-only.
/ MuteAPI Public archive

A simple API to mute player with or without a timer! Codet for PocketMine-MP

License

Notifications You must be signed in to change notification settings

supercrafter333/MuteAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MuteAPI - V1.1.0

A simple API to mute players!


Poggit Virion

Check the MuteAPI Virion out

How2Use?

Mute a player:

  • Time Muting Example:
<?php

namespace supercrafter333\TestPlugin;

use pocketmine\Player;
use pocketmine\plugin\PluginBase;
use supercrafter333\MuteAPI\MuteAPI;

class TestPlugin extends PluginBase
{
    
    /*Other stuff*/
    
    public function onCommand(CommandSender $sender,Command $command,string $label,array $args) : bool
    {
        if ($command == "mute") {
            if (!$sender instanceof Player) {
                $sender->sendMessage("Only In-Game!");
                return true;
            }
            if (count($args) >= 3) {
                $player = $this->getServer()->getPlayer($args[0]);
                if ($player === null) {
                    $sender->sendMessage("§cPlayer is not online!");
                    return true;
                }
                $reason = $args[1];
                $time = $args[2];
                $muteApi = new MuteAPI($this);
                $customPath = "/home/db/MuteAPI/"; //OPTIONAL!!
                $muteMgr = $muteApi->getMuteMgr("§cYou're Muted! You can't send a message, when you're muted!", $customPath);
                $playerData = $muteMgr->getPlayerData($player);
                if (!$time instanceof \DateInterval) {
                    $sender->sendMessage("§cPlease use the §7DateInterval§c format!");
                    return true;
                }
                $playerData->setTimeMuted(true, $player, $reason, $time);
                $sender->sendMessage("§aYou've successfully muted the player §7" . $player->getName() . "§a!");
                $player->sendMessage("§aYou're now muted by §7" . $sender->getName() . "§a!");
            }
        }
    }
}
  • Simple Muting Example:
<?php

namespace supercrafter333\TestPlugin;

use pocketmine\Player;
use pocketmine\plugin\PluginBase;
use supercrafter333\MuteAPI\MuteAPI;

class TestPlugin extends PluginBase
{
    
    /*Other stuff*/
    
    public function onCommand(CommandSender $sender,Command $command,string $label,array $args) : bool
    {
        if ($command == "mute") {
            if (!$sender instanceof Player) {
                $sender->sendMessage("Only In-Game!");
                return true;
            }
            if (count($args) >= 2) {
                $player = $this->getServer()->getPlayer($args[0]);
                if ($player === null) {
                    $sender->sendMessage("§cPlayer is not online!");
                    return true;
                }
                $reason = $args[1];
                $muteApi = new MuteAPI($this);
                $muteMgr = $muteApi->getMuteMgr("§cYou're Muted! You can't send a message, when you're muted!");
                $playerData = $muteMgr->getPlayerData($player);
                $playerData->setMuted(true, $reason);
                $sender->sendMessage("§aYou've successfully muted the player §7" . $player->getName() . "§a!");
                $player->sendMessage("§aYou're now muted by §7" . $sender->getName() . "§a!");
            }
        }
    }
}
  • Is Muted Example:
public function onChat(\pocketmine\event\player\PlayerChatEvent $event)
{
    $player = $event->getPlayer();
    $muteApi = new MuteAPI($this);
    $muteMgr = $muteApi->getMuteMgr("§cYou're Muted! You can't send a message, when you're muted!");
    $playerData = $muteMgr->getPlayerData($player);
    if ($playerData->isMuted()) {
        $player->sendMessage($muteMgr->getMuteMessage());
        $event->setCancelled(true);
    }
}

License

MuteAPI is Licensed under the Apache 2.0 License by supercrafter333!

About

A simple API to mute player with or without a timer! Codet for PocketMine-MP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages