Skip to content

Commit

Permalink
Rename game modules folder, add documentation for some modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ex4dev committed Jan 7, 2024
1 parent 95f2c4d commit edc0bfc
Show file tree
Hide file tree
Showing 50 changed files with 115 additions and 18 deletions.
23 changes: 23 additions & 0 deletions src/content/docs/reference/Game Modules/AwardsModule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: AwardsModule
---
`AwardsModule` is used to give the player coins and XP as a reward for doing well in games. XP is actually just the total number of coins you have earned, so if you earn 100 coins, you earn 100 XP at the same time.

## Usage
Import the module:
```kotlin
import com.bluedragonmc.server.module.database.AwardsModule
```
Use the module in your game's `initialize` function:
```kotlin
use(AwardsModule())
```

### Custom Awards
Now, you can use the `awardCoins` method to give coins and XP to the player. This will also send them a message letting them know that they earned coins, and a level up screen if the new XP got them to the next level.
```kotlin
getModule<AwardsModule>().awardCoins(player, amount, reason);
```

### Award for Winning
The [WinModule](../winmodule/) has a feature to automatically award coins at the end of a game. You still need to use `AwardsModule` for this feature to work.
8 changes: 8 additions & 0 deletions src/content/docs/reference/Game Modules/ChestLootModule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: ChestLootModule
---
`ChestLootModule` adds items to the inventory of a chest when it is first opened.

## Dependencies
This module depends on the following modules:
- [ChestModule](../chestmodule/) (has other dependencies)
22 changes: 22 additions & 0 deletions src/content/docs/reference/Game Modules/ChestModule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: ChestModule
---
`ChestModule` assigns a `Menu` to every chest in the world and allows them to be accessed by interacting with the chest. Additionally, the module assigns an ender chest to every player, which can be accessed by interacting with any ender chest block. Combine with [ChestLootModule](../chestlootmodule/) to add auto-generated loot to chests.

As stated in the Minestom README, this module is necessary for the following reason:
> Minestom by default does not know what is a chest, you will have to tell him that it opens an inventory. Every "special blocks" (which aren't only visual) need a specialized handler. After applying this handler, you have a block that can be placed anywhere simply. However, all blocks are visually there, they just won't have interaction by default.
## Dependencies
This module depends on the following modules:
- [GuiModule](../guimodule/)

## Usage
Import the module:
```kotlin
import com.bluedragonmc.server.module.vanilla.ChestModule
```
Use the module in your game's `initialize` function:
```kotlin
use(ChestModule())
```
By default, every chest will start empty. The [ChestLootModule](../chestlootmodule/) can be used to add starting items to chests. Alternatively, you can implement your own loot system with `ChestPopulateEvent`, which is called just before a chest is opened for the first time.
26 changes: 26 additions & 0 deletions src/content/docs/reference/Game Modules/FallDamageModule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: FallDamageModule
---
`FallDamageModule` implements fall damage, similar to what you would see on a vanilla server.

## Fall Damage Reduction
Certain blocks reduce the amount of fall damage the player takes if they land on them:
- Hay and honey blocks reduce fall damage by 20%
- Beds reduce fall damage by 50%
- Sweet berry bushes and cobwebs negate all fall damage
- Slime blocks negate all fall damage if the player is not sneaking

Certain armor enchantments further reduce fall damage:
- Feather falling reduces fall damage by 12% per level
- Protection reduces fall damage by 4% per level

## Usage
Import the module:
```kotlin
import com.bluedragonmc.server.module.vanilla.FallDamageModule
```
Use the module in your game's `initialize` function:
```kotlin
use(FallDamageModule())
```
Fall damage will be active as long as the module is in use.
32 changes: 32 additions & 0 deletions src/content/docs/reference/Game Modules/PlayerResetModule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: PlayerResetModule
---
`PlayerResetModule` changes some basic attributes about the player when they join the game, to avoid having changes to the player persist in between games.
> It is recommended to always use this module to ensure the player always starts in the same state.
## Effects
The module applies the following effects to the player upon joining the game
- Change game mode (if the `defaultGameMode` parameter is set)
- Clear inventory
- Reset health/hunger
- Reset movement speed
- Clear potion effects
- Disable flying
- Stop fire damage
- Disable glowing
- Reset XP
- Clear all tags

## Usage
Import the module:
```kotlin
import com.bluedragonmc.server.module.minigame.PlayerResetModule
```
Use the module in your game's `initialize` function:
```kotlin
use(PlayerResetModule(defaultGameMode = GameMode.ADVENTURE))
```
Now, when a player joins the game, the effects listed above will be applied to them. If you ever want to do this manually, you can use the `resetPlayer` method:
```kotlin
getModule<PlayerResetModule>().resetPlayer(player, gameMode)
```
4 changes: 4 additions & 0 deletions src/content/docs/reference/Game Modules/SpectatorModule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: SpectatorModule
---
`SpectatorModule` is used to manage spectators in a game. Spectators are considered to be "out of the game", and are generally not affected by events that occur inside the game. Many other modules use `SpectatorModule` to avoid taking action on spectators.
3 changes: 0 additions & 3 deletions src/content/docs/reference/game-modules/AwardsModule.md

This file was deleted.

3 changes: 0 additions & 3 deletions src/content/docs/reference/game-modules/ChestLootModule.md

This file was deleted.

3 changes: 0 additions & 3 deletions src/content/docs/reference/game-modules/ChestModule.md

This file was deleted.

3 changes: 0 additions & 3 deletions src/content/docs/reference/game-modules/FallDamageModule.md

This file was deleted.

3 changes: 0 additions & 3 deletions src/content/docs/reference/game-modules/PlayerResetModule.md

This file was deleted.

3 changes: 0 additions & 3 deletions src/content/docs/reference/game-modules/SpectatorModule.md

This file was deleted.

0 comments on commit edc0bfc

Please sign in to comment.