Advertisement
Guest User

Untitled

a guest
Aug 14th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. namespace ClearLagg;
  2. use pocketmine\command\Command;
  3. use pocketmine\command\CommandSender;
  4. use pocketmine\command\PluginIdentifiableCommand;
  5. use pocketmine\plugin\Plugin;
  6. class ClearLaggCommand extends Command implements PluginIdentifiableCommand {
  7. /** @var Loader */
  8. private $plugin;
  9. public function __construct(Loader $plugin) {
  10. parent::__construct("clearlagg", "Clear the lag!", "/clearlagg <check/clear/killmobs/clearall>", ["lagg"]);
  11. $this->setPermission("clearlagg.command.clearlagg");
  12. $this->plugin = $plugin;
  13. }
  14. /**
  15. * @return Plugin|Loader
  16. */
  17. public function getPlugin(): Plugin {
  18. return $this->plugin;
  19. }
  20. public function execute(CommandSender $sender, string $alias, array $args): bool {
  21. if(!$this->testPermission($sender)) {
  22. return false;
  23. }
  24. if(isset($args[0])) {
  25. switch($args[0]) {
  26. case "clear":
  27. $sender->sendMessage("Removed " . $this->getPlugin()->removeEntities() . " entities.");
  28. return true;
  29. case "check":
  30. case "count":
  31. $c = $this->getPlugin()->getEntityCount();
  32. $sender->sendMessage("There are " . $c[0] . " players, " . $c[1] . " mobs, and " . $c[2] . " entities.");
  33. return true;
  34. case "reload":
  35. // TODO
  36. return true;
  37. case "killmobs":
  38. $sender->sendMessage("Removed " . $this->getPlugin()->removeMobs() . " mobs.");
  39. return true;
  40. case "clearall":
  41. $sender->sendMessage("Removed " . ($d = $this->getPlugin()->removeMobs()) . " mob" . ($d == 1 ? "" : "s") . " and " . ($d = $this->getPlugin()->removeEntities()) . " entit" . ($d == 1 ? "y" : "ies") . ".");
  42. return true;
  43. case "area":
  44. // TODO
  45. return true;
  46. case "unloadchunks":
  47. // TODO
  48. return true;
  49. case "chunk":
  50. // TODO
  51. return true;
  52. case "tpchunk":
  53. // TODO
  54. return true;
  55. default:
  56. return false;
  57. }
  58. }
  59. return false;
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement