This repository was archived by the owner on Jun 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDisableCommand.php
More file actions
80 lines (68 loc) · 2.62 KB
/
DisableCommand.php
File metadata and controls
80 lines (68 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
namespace ServerCore\command;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\command\PluginIdentifiableCommand;
use pocketmine\plugin\Plugin;
use pocketmine\utils\TextFormat;
use pocketmine\Player;
use ServerCore\ServerCore as Main;
class DisableCommand extends Command implements PluginIdentifiableCommand {
private $plugin;
public function __construct(Main $plugin) {
$this->plugin = $plugin;
parent::__construct(
"disable",
"Disables certain features for a player",
"/disable <feature> <player>"
);
$this->setPermission("command.disable");
}
public function getPlugin() : Plugin {
return $this->plugin;
}
public function execute(CommandSender $sender, string $label, array $args) {
if (!$this->testPermission($sender)) {
return;
}
if (!isset($args[0]) || !isset($args[1])) {
$sender->sendMessage($this->getUsage());
return;
}
$player = $this->plugin->getServer()->getPlayer($args[1]);
if ($player === null) {
$sender->sendMessage(TextFormat::RED . "Player not found");
return;
}
$dbPath = $this->plugin->getServer()->getOnlineMode() ? $player->getXuid() : strtolower($player->getName());
$config = new Config($this->plugin->getDataFolder() . 'players/' . $dbPath, Config::YAML, [
"break" => true,
"place" => true,
"chat" => true
]);
switch ($args[0]) {
case "block":
case "blocks":
$config->set('break', false);
$config->set('place', false);
$config->save();
$sender->sendMessage(TextFormat::GREEN . "Block placing and breaking has been disabled for " . $player->getName());
break;
case "place":
$config->set('place', false);
$config->save();
$sender->sendMessage(TextFormat::GREEN . "Block placement has been disabled for " . $player->getName());
break;
case "break":
$config->set('break', false);
$config->save();
$sender->sendMessage(TextFormat::GREEN . "Block breaking has been disabled for " . $player->getName());
break;
case "chat":
$config->set('chat', false);
$config->save();
$sender->sendMessage(TextFormat::GREEN . "Chat has been disabled for " . $player->getName());
break;
}
}
}