An highly customisable UHC plugin for PocketMine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Scenario.php 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. # _ _ _ _ _____
  3. # | | | | | | |/ ____|
  4. # | | | | |__| | |
  5. # | | | | __ | |
  6. # | |__| | | | | |____
  7. # \____/|_| |_|\_____|
  8. # The most customisable UHC plugin for Minecraft PE !
  9. namespace Ad5001\UHC\scenario;
  10. use pocketmine\command\CommandExecutor;
  11. use pocketmine\command\Command;
  12. use pocketmine\command\CommandSender;
  13. use pocketmine\command\PluginIdentifiableCommand;
  14. use pocketmine\Server;
  15. use pocketmine\Player;
  16. use pocketmine\event\Listener;
  17. use pocketmine\utils\Config;
  18. use Ad5001\UHC\scenario\ScenarioInt;
  19. use Ad5001\UHC\Main;
  20. use Ad5001\UHC\UHCWorld;
  21. abstract class Scenario implements ScenarioInt, Listener {
  22. private $server;
  23. private $game;
  24. private $level;
  25. public function __construct(Server $server, UHCWorld $level) {
  26. $this->server = $server;
  27. $this->level = $level;
  28. }
  29. public function onStart() {}
  30. public function onStop() {}
  31. public function onJoin(Player $player) {}
  32. public function onQuit(Player $player) {}
  33. public function getLevel() {
  34. return $this->level;
  35. }
  36. public function getGame() {
  37. if(isset($this->main->UHCManager->getStartedUHCs()[$this->level->getName()])) {
  38. return $this->main->UHCManager->getStartedUHCs()[$this->level->getName()];
  39. }
  40. return null;
  41. }
  42. public function onInteract(\pocketmine\event\player\PlayerInteractEvent $event) {}
  43. public function onChat(\pocketmine\event\player\PlayerChatEvent $event) {}
  44. public function onPlayerChat(\pocketmine\event\player\PlayerChatEvent $event) {}
  45. public function onPlayerCommand(\pocketmine\event\player\PlayerCommandPreprocessEvent $event) {}
  46. public function onDeath(\pocketmine\event\player\PlayerDeathEvent $event) {}
  47. public function onPlayerDeath(\pocketmine\event\player\PlayerDeathEvent $event) {}
  48. public function onPlayerDropItem(\pocketmine\event\player\PlayerDropItemEvent $event) {}
  49. public function onDrop(\pocketmine\event\player\PlayerDropItemEvent $event) {}
  50. public function onPlayerMove(\pocketmine\event\player\PlayerMoveEvent $event) {}
  51. public function onMove(\pocketmine\event\player\PlayerMoveEvent $event) {}
  52. public function onPlayerItemConsume(\pocketmine\event\player\PlayerItemConsumeEvent $event) {}
  53. public function onItemConsume(\pocketmine\event\player\PlayerItemConsumeEvent $event) {}
  54. public function onPlayerItemHeld(\pocketmine\event\player\PlayerItemHeldEvent $event) {}
  55. public function onItemHeld(\pocketmine\event\player\PlayerItemHeldEvent $event) {}
  56. public function onDataPacketReceive(\pocketmine\event\server\DataPacketReceiveEvent $event) {}
  57. public function onDataPacketSend(\pocketmine\event\server\DataPacketSendEvent $event) {}
  58. public function onServerCommand(\pocketmine\event\server\ServerCommandEvent $event) {}
  59. public function onBlockBreak(\pocketmine\event\block\BlockBreakEvent $event) {}
  60. public function onBreak(\pocketmine\event\block\BlockBreakEvent $event) {}
  61. public function onBlockPlace(\pocketmine\event\block\BlockPlaceEvent $event) {}
  62. public function onPlace(\pocketmine\event\block\BlockPlaceEvent $event) {}
  63. public function onEntityDamage(\pocketmine\event\entity\EntityDamageEvent $event) {}
  64. public function onProjectileLaunch(\pocketmine\event\entity\ProjectileLauchEvent $event) {}
  65. public function onProjectileHit(\pocketmine\event\entity\ProjectileHitEvent $event) {}
  66. public function getMain() {
  67. return $this->server->getPluginManager()->getPlugin("UHC");
  68. }
  69. public function getServer() {
  70. return $this->main->getServer();
  71. }
  72. public static function help() {
  73. return "This scenario does not purpose help.";
  74. }
  75. public function getLogger() {
  76. return $this->getMain()->getLogger();
  77. }
  78. public function getConfig() {
  79. return $this->getMain()->getConfig()->get("Scenarios")[$this->name];
  80. }
  81. public function reloadConfig() {
  82. $this->getMain()->reloadConfig();
  83. return $this->getMain()->getConfig()->get("Scenarios")[$this->name];
  84. }
  85. public function saveConfig($cfg) {
  86. $scenarios = $this->getMain()->getConfig()->get("Scenarios");
  87. $scenarios[$this->name] = $cfg;
  88. $this->getMain()->getConfig()->set("Scenarios", $scenarios);
  89. return $this->getMain()->getConfig->save();
  90. }
  91. public function getScenariosFolder() {
  92. return $this->getMain()->getDataFolder() . "scenarios/";
  93. }
  94. }