de.pewpewproject.lasertag.mixin.ServerPlayNetworkHandlerMixin   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A onPlayerMove(PlayerMoveC2SPacket,CallbackInfo) 0 9 2
1
package de.pewpewproject.lasertag.mixin;
2
3
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
4
import net.minecraft.server.network.ServerPlayNetworkHandler;
5
import org.spongepowered.asm.mixin.Mixin;
6
import org.spongepowered.asm.mixin.injection.At;
7
import org.spongepowered.asm.mixin.injection.Inject;
8
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
9
10
/**
11
 * Mixin into the ServerPlayerNetworkHandler.class to disable the "Player moved too quickly" warning while
12
 * loading a new map
13
 *
14
 * @author Étienne Muser
15
 */
16
@Mixin(ServerPlayNetworkHandler.class)
17
public abstract class ServerPlayNetworkHandlerMixin {
18
19
    @Inject(method = "onPlayerMove(Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket;)V", at = @At("HEAD"), cancellable = true)
20
    private void onPlayerMove(PlayerMoveC2SPacket packet, CallbackInfo ci) {
21
22
        // Get the game managers
23
        var gameManager = ((ServerPlayNetworkHandler)(Object)this).server.getOverworld().getServerLasertagManager();
24
        var arenaManager = gameManager.getArenaManager();
25
26
        if (arenaManager.isLoading()) {
27
            ci.cancel();
28
        }
29
    }
30
}
31