Class DiscordHook
java.lang.Object
net.sacredlabyrinth.phaed.simpleclans.hooks.discord.DiscordHook
- All Implemented Interfaces:
org.bukkit.event.Listener
Hooks SimpleClans and Discord, using DiscordSRV.
On server' startup:
- Creates categories and channels, respecting discord's limits.
- Removes invalid channels, resets permissions and roles.
Manages events:
- Clan creation/deletion
- ClanPlayer joining/resigning
- Player linking/unlinking
- ClanPlayer promoting/demoting
Currently, works with clan chat only.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancategoryExists(String categoryId) Checks if a category can be obtained by id.booleanchannelExists(String clanTag) Checks if a channel with the specified clan tag exists@Nullable github.scarsz.discordsrv.dependencies.jda.api.entities.CategoryCreates a new SimpleClansCategoryvoidcreateChannel(@NotNull String clanTag) Creates a newTextChannelin available SimpleClans' categories, otherwise creates one.booleandeleteChannel(@NotNull String channelName) Deletes channel from SimpleClans categories.List<github.scarsz.discordsrv.dependencies.jda.api.entities.Category> Optional<github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel> getCachedChannel(@NotNull String channelName) Retrieves channel in SimpleClans categories.List<github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel> List<github.scarsz.discordsrv.dependencies.jda.api.entities.Category> In most cases, you will usegetCachedCategories().Optional<github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel> getChannel(@NotNull String channelName) Retrieves the channel in SimpleClans categories.List<github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel> In most cases, you will usegetCachedChannels().@NotNull github.scarsz.discordsrv.dependencies.jda.api.entities.GuildgetGuild()@NotNull github.scarsz.discordsrv.dependencies.jda.api.entities.Role@Nullable github.scarsz.discordsrv.dependencies.jda.api.entities.MembergetMember(@NotNull ClanPlayer clanPlayer) voidonClanCreate(CreateClanEvent event) voidonClanDisband(DisbandClanEvent event) voidonMessageReceived(github.scarsz.discordsrv.api.events.DiscordGuildMessageReceivedEvent event) voidvoidvoidonPlayerDemote(PlayerDemoteEvent event) voidonPlayerLinking(github.scarsz.discordsrv.api.events.AccountLinkedEvent event) voidvoidonPlayerUnlinking(github.scarsz.discordsrv.api.events.AccountUnlinkedEvent event) protected void
-
Constructor Details
-
DiscordHook
-
-
Method Details
-
onMessageReceived
public void onMessageReceived(github.scarsz.discordsrv.api.events.DiscordGuildMessageReceivedEvent event) -
onClanDisband
-
onClanCreate
-
onPlayerClanLeave
-
onPlayerClanJoin
-
onPlayerPromote
-
onPlayerDemote
-
onPlayerLinking
public void onPlayerLinking(github.scarsz.discordsrv.api.events.AccountLinkedEvent event) -
onPlayerUnlinking
public void onPlayerUnlinking(github.scarsz.discordsrv.api.events.AccountUnlinkedEvent event) -
setupDiscord
protected void setupDiscord() -
getGuild
@NotNull public @NotNull github.scarsz.discordsrv.dependencies.jda.api.entities.Guild getGuild() -
getLeaderRole
@NotNull public @NotNull github.scarsz.discordsrv.dependencies.jda.api.entities.Role getLeaderRole()- Returns:
- A leader role from guild, otherwise creates one.
-
getLeaderColor
- Returns:
- A leader color from configuration
-
createCategory
@Nullable public @Nullable github.scarsz.discordsrv.dependencies.jda.api.entities.Category createCategory()Creates a new SimpleClansCategory- Returns:
- Category or null, if reached the limit
-
createChannel
public void createChannel(@NotNull @NotNull String clanTag) throws InvalidChannelException, CategoriesLimitException, ChannelsLimitException, ChannelExistsException Creates a newTextChannelin available SimpleClans' categories, otherwise creates one.Sets positive
Permission.VIEW_CHANNELpermission to all linked clan members.- Parameters:
clanTag- the clan tag- Throws:
InvalidChannelException- clan is not verified or permanent, no one member is linked or clan is not in the whitelist.ChannelExistsException- if channel is already existCategoriesLimitException- if categories reached the limit.ChannelsLimitException- if discord reached the channels limit.
-
getCachedChannel
public Optional<github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel> getCachedChannel(@NotNull @NotNull String channelName) Retrieves channel in SimpleClans categories.- Parameters:
channelName- the channel name- Returns:
- the channel
- See Also:
-
categoryExists
Checks if a category can be obtained by id.- Parameters:
categoryId- the category id- Returns:
- true if the category exists
- See Also:
-
channelExists
Checks if a channel with the specified clan tag exists- See Also:
-
getChannel
public Optional<github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel> getChannel(@NotNull @NotNull String channelName) Retrieves the channel in SimpleClans categories.- Parameters:
channelName- the channel name- Returns:
- the channel
- See Also:
-
deleteChannel
Deletes channel from SimpleClans categories. If there are no channels, removes category as well.- Parameters:
channelName- the channel name- Returns:
- true, if channel was deleted and false if not.
-
getCachedCategories
- Returns:
- categories from config
-
getCategories
In most cases, you will usegetCachedCategories().- Returns:
- categories from guild
-
getChannels
In most cases, you will usegetCachedChannels().- Returns:
- all channels from guild
-
getCachedChannels
- Returns:
- All channels in categories
-
getMember
@Nullable public @Nullable github.scarsz.discordsrv.dependencies.jda.api.entities.Member getMember(@NotNull @NotNull ClanPlayer clanPlayer)
-