getPlayerManager()
last analyzed

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 2
c 0
b 0
f 0
1
package de.pewpewproject.lasertag.mixin;
2
3
import net.minecraft.server.MinecraftServer;
4
import net.minecraft.server.PlayerManager;
5
import net.minecraft.server.world.ServerWorld;
6
import org.spongepowered.asm.mixin.Mixin;
7
import org.spongepowered.asm.mixin.Shadow;
8
import org.spongepowered.asm.mixin.injection.At;
9
import org.spongepowered.asm.mixin.injection.Inject;
10
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
11
12
/**
13
 * Interface injection into MinecraftServer to implement the lasertag game
14
 *
15
 * @author Étienne Muser
16
 */
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
}