de.pewpewproject.lasertag.lasertaggame.state.synced.implementation.ActivationState   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A deactivatePlayer(UUID) 0 3 1
A isActivated(UUID) 0 3 1
A activatePlayer(UUID) 0 3 1
1
package de.pewpewproject.lasertag.lasertaggame.state.synced.implementation;
2
3
import de.pewpewproject.lasertag.lasertaggame.state.synced.IActivationState;
4
5
import java.util.HashSet;
6
import java.util.UUID;
7
8
/**
9
 * Implementation of IActivationState for the lasertag game.
10
 *
11
 * @author Étienne Muser
12
 */
13
public class ActivationState implements IActivationState {
14
15
    /**
16
     * HashSet containing the uuids of all and only the
17
     * activated players.
18
     */
19
    private final HashSet<UUID> activatedPlayersUuids = new HashSet<>();
20
21
    @Override
22
    public synchronized boolean isActivated(UUID playerUuid) {
23
        return activatedPlayersUuids.contains(playerUuid);
24
    }
25
26
    @Override
27
    public synchronized void activatePlayer(UUID playerUuid) {
28
        activatedPlayersUuids.add(playerUuid);
29
    }
30
31
    @Override
32
    public synchronized void deactivatePlayer(UUID playerUuid) {
33
        activatedPlayersUuids.remove(playerUuid);
34
    }
35
}
36