| Total Complexity | 1 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package de.pewpewproject.lasertag.mixin; |
||
| 17 | @Mixin(MinecraftServer.class) |
||
| 18 | public abstract class MinecraftServerMixin { |
||
| 19 | |||
| 20 | @Shadow |
||
| 21 | public abstract PlayerManager getPlayerManager(); |
||
| 22 | |||
| 23 | @Shadow |
||
| 24 | public abstract ServerWorld getOverworld(); |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Inject into the stop method of the minecraft server. |
||
| 28 | * This method gets called after entering the /stop command or typing stop into the server console. |
||
| 29 | * |
||
| 30 | * @param ci |
||
| 31 | */ |
||
| 32 | @Inject(method = "shutdown", at = @At("HEAD")) |
||
| 33 | private void atShutdown(CallbackInfo ci) { |
||
| 34 | |||
| 35 | // Get the game managers |
||
| 36 | var gameManager = getOverworld().getServerLasertagManager(); |
||
| 37 | |||
| 38 | // Stop the lasertag game |
||
| 39 | gameManager.stopLasertagGame(); |
||
| 40 | |||
| 41 | // Dispose the game managers |
||
| 42 | gameManager.dispose(); |
||
| 43 | } |
||
| 44 | } |