Make minigames easilier !
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.

README.md 12KB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # GameManager
  2. Make minigames easier!
  3. Gamemanager is a plugin that makes writing a minigame much easier with its easy api, which is conveniently designed for per world minigames!
  4. I made this for me in the beginning but feel free to use it to write your own minigame!
  5. ### How to make a game:
  6. To make a game base, create a new file called "<**YOUR_GAME_NAME**>.php". Inside it, add a
  7. ```php
  8. <?php
  9. use Ad5001\GameManager\Game;
  10. use pocketmine\Player;
  11. class <YOUR_GAME_NAME> extends Game {
  12. public function onGameStart() { // When the game start (enought players)
  13. // $this->getServer()->broadcastMessage("Game started on {$this->getLevel()->getName()}");
  14. }
  15. public function onGameStop() { // When you stop the game.
  16. // $this->getServer()->broadcastMessage("Game stoped on {$this->getLevel()->getName()}");
  17. }
  18. public function getMaxPlayers() : int { // Return the max of the players
  19. return <NUMBER OF PLAYERS MAX>;
  20. }
  21. }
  22. ```
  23. This is the basic class.
  24. Methods that you can add to the class (optionals):
  25. | Function name | Arguments | When it is called ? | What does it do by default? |
  26. |-----------------------------------|---------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
  27. | onJoin | Player $player | When a player join the game. | It check if there are enought players that joined the game to start or kick the player from the game if there are too much players that have joined and game isn't started |
  28. | onQuit | Player $player | When a player quit the game | Nothing |
  29. | onCommand | \pocketmine\command\CommandSender $sender, \pocketmine\command\Command $cmd, $label, array $args | When a command (registered by the game (see registerCommand in methods)) is used by the console or a player. | Nothing |
  30. | onInteract | PlayerInteractEvent $event | When a player touch a block and is in the current game | Nothing |
  31. | onChat onPlayerChat | PlayerChatEvent $event | When a player chat and is in the current game | Nothing |
  32. | onPlayerCommand | PlayerCommandPreprocessEvent $event | When a player use a command, is in the current game, and the commmand haven't been processed yet | Nothing |
  33. | onDeath onPlayerDeath | PlayerDeathEvent $event | When a player die and is in the current game | Nothing |
  34. | onDrop onPlayerDropItem | PlayerDropItemEvent $event | When a player drop an item and is in the current game | Nothing |
  35. | onPlayerMove onMove | PlayerMoveEvent $event | When a player move in the current game | Nothing |
  36. | onPlayerItemConsume onItemConsume | PlayerItemConsumeEvent $event | When a player use an item in the current game | Nothing |
  37. | onPlayerItemHeld onItemHeld | PlayerItemHeldEvent $event | When a player switch item in the current game | Nothing |
  38. | onDataPacketReceive | DataPacketReceiveEvent $event | When the server receive a packet from a player in the current game | Nothing |
  39. | onDataPacketSend | DataPacketSendEvent $event | When the server send a packet to a player in the current game | Nothing |
  40. | onServerCommand | ServerCommandEvent $event | When the console or RCon send a command | Nothing |
  41. | onBlockBreak onBreak | BlockBreakEvent $event | When a player break a block in the current game. | Nothing |
  42. | onBlockPlace onPlace | BlockPlaceEvent $event | When a player place a block in the current game | Nothing |
  43. | onEntityDamage | EntityDamageEvent | When an entity get damage in the current game | Nothing |
  44. Methods that you can use in the class:
  45. | Function name | Arguments | What does it return ? |
  46. |-------------------|----------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------:|
  47. | getPlugin | None | Instance of the main class (Ad5001\GameManager\Main) |
  48. | getLevel | None | Intance of the current game level (pocketmine\level\Level) |
  49. | isStarted | None | Boolean if the game is already started (boolean) |
  50. | stop | None | Boolean true. Stop the game. |
  51. | start | None | Boolean true. Start the game. |
  52. | getLogger | None | Instance of the plugin logger (pocketmine\plugin\PluginLogger) |
  53. | saveDefaultConfig | None | Save a config that you will be able to use using the next function |
  54. | getConfig | None | Instance of the config (be sure of having used saveDefaultConfig)(pocketmine\utils\Config) |
  55. | getDataFolder | None | The path of the game data folder (string) |
  56. | registerCommand | string $cmd, string $desc, string $usage, array $aliases, string $perm = "gamemanager.command.use" | Null. Register command $cmd with the description $desc, usage $usage, aliases $aliases and permission $perm. |