isActivated(UUID)   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
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