/
SimpleVersionedItem.java
146 lines (122 loc) · 3.34 KB
/
SimpleVersionedItem.java
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package com.kantenkugel.discordbot.versioncheck.items;
import com.kantenkugel.discordbot.versioncheck.DependencyType;
import com.kantenkugel.discordbot.versioncheck.RepoType;
import gnu.trove.set.TLongSet;
import gnu.trove.set.hash.TLongHashSet;
import net.dv8tion.jda.api.entities.User;
import java.util.*;
/**
* Simple wrapper class for {@link VersionedItem}.
* <br/>This only supports maven artifacts and doesn't support advanced features like update handler, changelogs or custom versions.
* For these, please directly extend {@link VersionedItem}.
*/
public class SimpleVersionedItem extends VersionedItem
{
private final String name;
private List<String> aliases;
private final RepoType repoType;
private final Set<RepoType> additionalRepos;
private final DependencyType depType;
private final String groupId;
private final String artifactId;
private String url;
private long roleId = 0;
private long channelId = 0;
private final TLongSet allowedAnnouncers = new TLongHashSet();
public SimpleVersionedItem(String name, RepoType repoType, DependencyType depType, String groupId, String artifactId)
{
this(name, repoType, Collections.emptySet(), depType, groupId, artifactId);
}
public SimpleVersionedItem(String name, RepoType repoType, Set<RepoType> additionalRepos, DependencyType depType, String groupId, String artifactId)
{
this.name = name;
this.repoType = repoType;
this.additionalRepos = additionalRepos;
this.depType = depType;
this.groupId = groupId;
this.artifactId = artifactId;
}
public SimpleVersionedItem setAliases(String... aliases)
{
this.aliases = Arrays.asList(aliases);
return this;
}
public SimpleVersionedItem setUrl(String url)
{
this.url = url;
return this;
}
public SimpleVersionedItem setAnnouncementRoleId(long roleId)
{
this.roleId = roleId;
return this;
}
public SimpleVersionedItem setAnnouncementChannelId(long channelId)
{
this.channelId = channelId;
return this;
}
public SimpleVersionedItem addAnnouncementWhitelist(long... userIds)
{
allowedAnnouncers.addAll(userIds);
return this;
}
@Override
public String getName()
{
return name;
}
@Override
public String getDescription() {
return "Announcements for " + getName();
}
@Override
public List<String> getAliases()
{
return aliases;
}
@Override
public RepoType getRepoType()
{
return repoType;
}
@Override
public Set<RepoType> getAdditionalRepositories() {
return additionalRepos;
}
@Override
public DependencyType getDependencyType()
{
return depType;
}
@Override
public String getGroupId()
{
return groupId;
}
@Override
public String getArtifactId()
{
return artifactId;
}
@Override
public String getUrl()
{
return url;
}
@Override
public long getAnnouncementRoleId()
{
return roleId;
}
@Override
public long getAnnouncementChannelId()
{
return channelId;
}
@Override
public boolean canAnnounce(User u)
{
return allowedAnnouncers.contains(u.getIdLong());
}
}