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

init(Logger)   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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