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-2019 Vincent Quatrevieux |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
package fr.quatrevieux.araknemu.game.chat.channel; |
21
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.game.chat.ChannelType; |
23
|
|
|
import fr.quatrevieux.araknemu.game.chat.ChatException; |
24
|
|
|
import fr.quatrevieux.araknemu.game.chat.event.BroadcastedMessage; |
25
|
|
|
import fr.quatrevieux.araknemu.game.player.GamePlayer; |
26
|
|
|
import fr.quatrevieux.araknemu.network.game.in.chat.Message; |
27
|
|
|
import fr.quatrevieux.araknemu.network.game.out.info.Information; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The fight team chat : send to all teammates fighters |
31
|
|
|
*/ |
32
|
1 |
|
public final class FightTeamChannel implements Channel { |
33
|
|
|
@Override |
34
|
|
|
public ChannelType type() { |
35
|
1 |
|
return ChannelType.FIGHT_TEAM; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
@Override |
39
|
|
|
public boolean authorized(GamePlayer from) { |
40
|
1 |
|
return from.isFighting(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
@Override |
44
|
|
|
public void send(GamePlayer from, Message message) throws ChatException { |
45
|
1 |
|
if (!message.items().isEmpty()) { |
46
|
1 |
|
from.send(Information.cannotPostItemOnChannel()); |
47
|
1 |
|
return; |
48
|
|
|
} |
49
|
|
|
|
50
|
1 |
|
final BroadcastedMessage event = new BroadcastedMessage(type(), from, message.message(), ""); |
51
|
|
|
|
52
|
1 |
|
from |
53
|
1 |
|
.fighter() |
54
|
1 |
|
.team() |
55
|
1 |
|
.fighters() |
56
|
1 |
|
.forEach(player -> player.dispatch(event)) |
57
|
|
|
; |
58
|
1 |
|
} |
59
|
|
|
} |
60
|
|
|
|