Passed
Push — main ( b981dd...7422f7 )
by Etienne
01:33
created

tick()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
dl 0
loc 2
rs 10
1
package de.kleiner3.lasertag.lasertaggame.management.blocktick;
2
3
import de.kleiner3.lasertag.block.entity.LasertagCustomBlockTickable;
4
import de.kleiner3.lasertag.lasertaggame.management.IManager;
5
import net.minecraft.server.MinecraftServer;
6
7
import java.util.ArrayList;
8
import java.util.List;
9
10
/**
11
 * Manages the custom lasertag block ticks. This a workaround for the weird behaviour observed when reloading the arena.
12
 *
13
 * @author Étienne Muser
14
 */
15
public class LasertagBlockTickManager implements IManager {
16
17
    private final List<LasertagCustomBlockTickable> blockEntityTickers;
18
    private final MinecraftServer server;
19
20
    public LasertagBlockTickManager(MinecraftServer server) {
21
        this.blockEntityTickers = new ArrayList<>();
22
        this.server = server;
23
    }
24
25
    public void registerTicker(LasertagCustomBlockTickable ticker) {
26
        blockEntityTickers.add(ticker);
27
    }
28
29
    public void clear() {
30
        this.blockEntityTickers.clear();
31
    }
32
33
    public void tick() {
34
        blockEntityTickers.forEach(ticker -> ticker.serverTick(this.server.getOverworld()));
35
    }
36
37
    @Override
38
    public void dispose() {
39
        // Nothing to dispose
40
    }
41
}
42