Passed
Push — master ( dce7e6...e2e6ab )
by Vincent
06:59 queued 12s
created

fr.quatrevieux.araknemu.game.GameBanIpSynchronizer   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 72.72%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
dl 0
loc 30
ccs 8
cts 11
cp 0.7272
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A GameBanIpSynchronizer(BanIpService,Supplier,Logger,Duration) 0 2 1
$Listener$.event() 0 3 ?
$Listener$.on(GameStopped) 0 3 ?
A listeners() 0 15 3
A name() 0 3 1
A init(Logger) 0 3 1
1
/*
2
 * This file is part of Araknemu.
3
 *
4
 * Araknemu is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * Araknemu is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with Araknemu.  If not, see <https://www.gnu.org/licenses/>.
16
 *
17
 * Copyright (c) 2017-2020 Vincent Quatrevieux
18
 */
19
20
package fr.quatrevieux.araknemu.game;
21
22
import fr.quatrevieux.araknemu.common.account.banishment.AbstractBanIpSynchronizer;
23
import fr.quatrevieux.araknemu.common.account.banishment.BanIpService;
24
import fr.quatrevieux.araknemu.core.event.EventsSubscriber;
25
import fr.quatrevieux.araknemu.core.event.Listener;
26
import fr.quatrevieux.araknemu.core.network.session.Session;
27
import fr.quatrevieux.araknemu.game.account.GameAccount;
28
import fr.quatrevieux.araknemu.game.event.GameStopped;
29
import org.apache.logging.log4j.Logger;
30
31
import java.time.Duration;
32
import java.util.Collection;
33
import java.util.function.Supplier;
34
35
/**
36
 * Synchronize ban ip table for game service
37
 */
38
public final class GameBanIpSynchronizer extends AbstractBanIpSynchronizer implements EventsSubscriber, PreloadableService {
39
    public GameBanIpSynchronizer(BanIpService<GameAccount> service, Supplier<Collection<? extends Session>> sessionsSupplier, Logger logger, Duration refreshDelay) {
40 1
        super(service, sessionsSupplier, logger, refreshDelay);
41 1
    }
42
43
    @Override
44
    public void init(Logger logger) {
45
        startPulling();
46
    }
47
48
    @Override
49
    public String name() {
50
        return "banip";
51
    }
52
53
    @Override
54
    public Listener[] listeners() {
55 1
        return new Listener[] {
56 1
            new Listener<GameStopped>() {
57
                @Override
58
                public void on(GameStopped event) {
59 1
                    stopPulling();
60 1
                }
61
62
                @Override
63
                public Class<GameStopped> event() {
64 1
                    return GameStopped.class;
65
                }
66
            },
67 1
            ipBannedListener(),
68
        };
69
    }
70
}
71