-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathAbstractChannel.java
More file actions
100 lines (79 loc) · 2.5 KB
/
AbstractChannel.java
File metadata and controls
100 lines (79 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package at.helpch.chatchat.channel;
import at.helpch.chatchat.api.channel.Channel;
import at.helpch.chatchat.api.holder.FormatsHolder;
import at.helpch.chatchat.api.user.ChatUser;
import at.helpch.chatchat.util.ChannelUtils;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public abstract class AbstractChannel implements Channel {
private final String name;
private final String messagePrefix;
private final List<String> toggleCommands;
private final String channelPrefix;
private final FormatsHolder formats;
private final int radius;
private final boolean crossServer;
protected AbstractChannel(
@NotNull final String name,
@NotNull final String messagePrefix,
@NotNull final List<String> toggleCommands,
@NotNull final String channelPrefix,
@NotNull final FormatsHolder formats,
final int radius,
final boolean crossServer
) {
this.name = name;
this.messagePrefix = messagePrefix;
this.toggleCommands = toggleCommands;
this.channelPrefix = channelPrefix;
this.formats = formats;
this.radius = radius;
this.crossServer = crossServer;
}
@Override
public @NotNull String name() {
return name;
}
@Override
public @NotNull String messagePrefix() {
return messagePrefix;
}
@Override
public @NotNull String channelPrefix() {
return channelPrefix;
}
@Override
public @NotNull List<String> commandNames() {
return toggleCommands;
}
@Override
public @NotNull FormatsHolder formats() {
return formats;
}
@Override
public int radius() {
return radius;
}
@Override
public boolean crossServer() {
return crossServer;
}
@Override
public boolean isUsableBy(@NotNull final ChatUser user) {
if (ChatChannel.defaultChannel().equals(this)) {
return true;
}
return user.hasPermission(ChannelUtils.USE_CHANNEL_PERMISSION + name());
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AbstractChannel that = (AbstractChannel) o;
return name.equals(that.name()) &&
messagePrefix.equals(that.messagePrefix()) &&
toggleCommands.equals(that.commandNames()) &&
channelPrefix.equals(that.channelPrefix()) &&
radius == that.radius();
}
}