file_name
stringlengths
6
86
file_path
stringlengths
45
249
content
stringlengths
47
6.26M
file_size
int64
47
6.26M
language
stringclasses
1 value
extension
stringclasses
1 value
repo_name
stringclasses
767 values
repo_stars
int64
8
14.4k
repo_forks
int64
0
1.17k
repo_open_issues
int64
0
788
repo_created_at
stringclasses
767 values
repo_pushed_at
stringclasses
767 values
DiscordMessageUpdateEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageUpdateEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.message; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessage; import net.dv8tion.jda.api.events.message.MessageUpdateEvent; public class DiscordMessageUpdateEvent extends AbstractDiscordMessageEvent<MessageUpdateEvent> { private final ReceivedDiscordMessage message; public DiscordMessageUpdateEvent(MessageUpdateEvent jdaEvent, DiscordMessageChannel channel, ReceivedDiscordMessage message) { super(jdaEvent, channel); this.message = message; } public ReceivedDiscordMessage getMessage() { return message; } }
1,962
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AbstractDiscordMemberEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/member/AbstractDiscordMemberEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.member; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.event.events.discord.AbstractDiscordEvent; import net.dv8tion.jda.api.events.guild.member.GenericGuildMemberEvent; public abstract class AbstractDiscordMemberEvent<T extends GenericGuildMemberEvent> extends AbstractDiscordEvent<T> { private final DiscordGuildMember member; public AbstractDiscordMemberEvent(T jdaEvent, DiscordGuildMember member) { super(jdaEvent); this.member = member; } public DiscordGuildMember getMember() { return member; } }
1,908
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AbstractDiscordMemberRoleChangeEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/AbstractDiscordMemberRoleChangeEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.member.role; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.guild.DiscordRole; import com.discordsrv.api.event.events.discord.member.AbstractDiscordMemberEvent; import net.dv8tion.jda.api.events.guild.member.GenericGuildMemberEvent; import java.util.List; public abstract class AbstractDiscordMemberRoleChangeEvent<T extends GenericGuildMemberEvent> extends AbstractDiscordMemberEvent<T> { private final List<DiscordRole> roles; public AbstractDiscordMemberRoleChangeEvent(T jdaEvent, DiscordGuildMember member, List<DiscordRole> roles) { super(jdaEvent, member); this.roles = roles; } public List<DiscordRole> getRoles() { return roles; } }
2,062
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordMemberRoleRemoveEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleRemoveEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.member.role; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.guild.DiscordRole; import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent; import java.util.List; public class DiscordMemberRoleRemoveEvent extends AbstractDiscordMemberRoleChangeEvent<GuildMemberRoleRemoveEvent> { public DiscordMemberRoleRemoveEvent(GuildMemberRoleRemoveEvent jdaEvent, DiscordGuildMember member, List<DiscordRole> roles) { super(jdaEvent, member, roles); } }
1,847
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordMemberRoleAddEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleAddEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.member.role; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.guild.DiscordRole; import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleAddEvent; import java.util.List; public class DiscordMemberRoleAddEvent extends AbstractDiscordMemberRoleChangeEvent<GuildMemberRoleAddEvent> { public DiscordMemberRoleAddEvent(GuildMemberRoleAddEvent jdaEvent, DiscordGuildMember member, List<DiscordRole> roles) { super(jdaEvent, member, roles); } }
1,832
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AbstractDeferrableInteractionEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractDeferrableInteractionEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.interaction; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; import net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent; import org.jetbrains.annotations.NotNull; public abstract class AbstractDeferrableInteractionEvent<T extends GenericInteractionCreateEvent> extends AbstractInteractionEvent<T> { protected final DiscordInteractionHook hook; public AbstractDeferrableInteractionEvent( T jdaEvent, ComponentIdentifier identifier, DiscordUser user, DiscordGuildMember member, DiscordMessageChannel channel, DiscordInteractionHook hook ) { super(jdaEvent, identifier, user, member, channel); this.hook = hook; } @NotNull public DiscordInteractionHook hook() { return hook; } }
2,437
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordModalInteractionEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/DiscordModalInteractionEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.interaction; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent; public class DiscordModalInteractionEvent extends AbstractDeferrableInteractionEvent<ModalInteractionEvent> { public DiscordModalInteractionEvent( ModalInteractionEvent jdaEvent, ComponentIdentifier identifier, DiscordUser user, DiscordGuildMember member, DiscordMessageChannel channel, DiscordInteractionHook hook ) { super(jdaEvent, identifier, user, member, channel, hook); } }
2,221
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AbstractInteractionEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractInteractionEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.interaction; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuild; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; import com.discordsrv.api.event.events.discord.AbstractDiscordEvent; import net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public abstract class AbstractInteractionEvent<T extends GenericInteractionCreateEvent> extends AbstractDiscordEvent<T> { protected final ComponentIdentifier identifier; protected final DiscordUser user; protected final DiscordGuildMember member; protected final DiscordMessageChannel channel; public AbstractInteractionEvent( T jdaEvent, ComponentIdentifier identifier, DiscordUser user, DiscordGuildMember member, DiscordMessageChannel channel ) { super(jdaEvent); this.identifier = identifier; this.user = user; this.member = member; this.channel = channel; } public boolean isFor(ComponentIdentifier identifier) { return this.identifier.equals(identifier); } @NotNull public DiscordUser getUser() { return user; } @Nullable public DiscordGuildMember getMember() { return member; } public DiscordGuild getGuild() { return member != null ? member.getGuild() : null; } @NotNull public DiscordMessageChannel getChannel() { return channel; } }
3,063
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordMessageContextInteractionEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordMessageContextInteractionEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; import net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent; public abstract class DiscordMessageContextInteractionEvent extends AbstractCommandInteractionEvent<MessageContextInteractionEvent> { public DiscordMessageContextInteractionEvent( MessageContextInteractionEvent jdaEvent, ComponentIdentifier identifier, DiscordUser user, DiscordGuildMember member, DiscordMessageChannel channel, DiscordInteractionHook interaction ) { super(jdaEvent, identifier, user, member, channel, interaction); } }
2,310
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordChatInputInteractionEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordChatInputInteractionEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; public abstract class DiscordChatInputInteractionEvent extends AbstractCommandInteractionEvent<SlashCommandInteractionEvent> { public DiscordChatInputInteractionEvent( SlashCommandInteractionEvent jdaEvent, ComponentIdentifier identifier, DiscordUser user, DiscordGuildMember member, DiscordMessageChannel channel, DiscordInteractionHook interaction ) { super(jdaEvent, identifier, user, member, channel, interaction); } }
2,286
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordCommandAutoCompleteInteractionEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordCommandAutoCompleteInteractionEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; import com.discordsrv.api.event.events.discord.interaction.AbstractInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent; import net.dv8tion.jda.api.interactions.commands.OptionMapping; import java.util.LinkedHashMap; import java.util.Map; public class DiscordCommandAutoCompleteInteractionEvent extends AbstractInteractionEvent<CommandAutoCompleteInteractionEvent> { private final Map<String, Object> choices = new LinkedHashMap<>(); public DiscordCommandAutoCompleteInteractionEvent( CommandAutoCompleteInteractionEvent jdaEvent, ComponentIdentifier identifier, DiscordUser user, DiscordGuildMember member, DiscordMessageChannel channel ) { super(jdaEvent, identifier, user, member, channel); } public String getOption(String name) { OptionMapping mapping = jdaEvent.getOption(name); return mapping != null ? mapping.getAsString() : null; } public void addChoice(String name, String value) { this.choices.put(name, value); } public void addChoice(String name, double value) { this.choices.put(name, value); } public void addChoice(String name, long value) { this.choices.put(name, value); } public Map<String, Object> getChoices() { return choices; } }
2,998
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordUserContextInteractionEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordUserContextInteractionEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; import net.dv8tion.jda.api.events.interaction.command.UserContextInteractionEvent; public abstract class DiscordUserContextInteractionEvent extends AbstractCommandInteractionEvent<UserContextInteractionEvent> { public DiscordUserContextInteractionEvent( UserContextInteractionEvent jdaEvent, ComponentIdentifier identifier, DiscordUser user, DiscordGuildMember member, DiscordMessageChannel channel, DiscordInteractionHook interaction ) { super(jdaEvent, identifier, user, member, channel, interaction); } }
2,287
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
CommandRegisterEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/CommandRegisterEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.interaction.command.DiscordCommand; import com.discordsrv.api.event.events.Event; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Unmodifiable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; /** * An event for registering {@link DiscordCommand}s, * an alternative to {@link com.discordsrv.api.discord.DiscordAPI#registerCommand(DiscordCommand)}. */ public class CommandRegisterEvent implements Event { private final List<DiscordCommand> commands = new ArrayList<>(); /** * Add events to be registered. * @param commands the commands to be registered, use of the same command instances is recommended */ public void registerCommands(@NotNull DiscordCommand... commands) { this.commands.addAll(Arrays.asList(commands)); } @NotNull @Unmodifiable public List<DiscordCommand> getCommands() { return Collections.unmodifiableList(commands); } }
2,367
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AbstractCommandInteractionEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/AbstractCommandInteractionEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; import com.discordsrv.api.discord.entity.message.SendableDiscordMessage; import com.discordsrv.api.event.events.discord.interaction.AbstractDeferrableInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent; import net.dv8tion.jda.api.interactions.commands.OptionMapping; import org.jetbrains.annotations.Nullable; import java.util.concurrent.CompletableFuture; public abstract class AbstractCommandInteractionEvent<E extends GenericCommandInteractionEvent> extends AbstractDeferrableInteractionEvent<E> { public AbstractCommandInteractionEvent( E jdaEvent, ComponentIdentifier identifier, DiscordUser user, DiscordGuildMember member, DiscordMessageChannel channel, DiscordInteractionHook interaction ) { super(jdaEvent, identifier, user, member, channel, interaction); } public abstract CompletableFuture<DiscordInteractionHook> reply(SendableDiscordMessage message, boolean ephemeral); public CompletableFuture<DiscordInteractionHook> reply(SendableDiscordMessage message) { return reply(message, false); } @Nullable public String getOption(String name) { OptionMapping mapping = jdaEvent.getOption(name); return mapping != null ? mapping.getAsString() : null; } }
3,052
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordButtonInteractionEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordButtonInteractionEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.interaction.component; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; import com.discordsrv.api.event.events.discord.interaction.AbstractDeferrableInteractionEvent; import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent; public class DiscordButtonInteractionEvent extends AbstractDeferrableInteractionEvent<ButtonInteractionEvent> { public DiscordButtonInteractionEvent( ButtonInteractionEvent jdaEvent, ComponentIdentifier identifier, DiscordUser user, DiscordGuildMember member, DiscordMessageChannel channel, DiscordInteractionHook interaction ) { super(jdaEvent, identifier, user, member, channel, interaction); } }
2,355
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordSelectMenuInteractionEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordSelectMenuInteractionEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.discord.interaction.component; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.interaction.DiscordInteractionHook; import com.discordsrv.api.discord.entity.interaction.component.ComponentIdentifier; import com.discordsrv.api.event.events.discord.interaction.AbstractDeferrableInteractionEvent; import net.dv8tion.jda.api.events.interaction.component.GenericSelectMenuInteractionEvent; public class DiscordSelectMenuInteractionEvent extends AbstractDeferrableInteractionEvent<GenericSelectMenuInteractionEvent<?, ?>> { public DiscordSelectMenuInteractionEvent( GenericSelectMenuInteractionEvent<?, ?> jdaEvent, ComponentIdentifier identifier, DiscordUser user, DiscordGuildMember member, DiscordMessageChannel channel, DiscordInteractionHook interaction ) { super(jdaEvent, identifier, user, member, channel, interaction); } }
2,408
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordSRVConnectedEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVConnectedEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.lifecycle; import com.discordsrv.api.event.events.Event; /** * Indicates that DiscordSRV's Discord connection has been (re-)established. This may run more than once. */ public class DiscordSRVConnectedEvent implements Event { }
1,534
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordSRVReadyEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVReadyEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.lifecycle; import com.discordsrv.api.event.events.Event; /** * Indicates that DiscordSRV is ready (including Discord connection), this only runs once when DiscordSRV enables. */ public class DiscordSRVReadyEvent implements Event { }
1,538
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordSRVReloadedEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVReloadedEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.lifecycle; import com.discordsrv.api.DiscordSRVApi; import com.discordsrv.api.event.events.Event; import java.util.Set; /** * An event for when DiscordSRV successfully reloads partially or completely. */ public class DiscordSRVReloadedEvent implements Event { private final Set<DiscordSRVApi.ReloadFlag> flags; public DiscordSRVReloadedEvent(Set<DiscordSRVApi.ReloadFlag> flags) { this.flags = flags; } /** * Set of DiscordSRV systems that were reloaded. * @return an unmodifiable set of {@link com.discordsrv.api.DiscordSRVApi.ReloadFlag}s */ public Set<DiscordSRVApi.ReloadFlag> flags() { return flags; } }
1,973
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordSRVShuttingDownEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVShuttingDownEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.lifecycle; import com.discordsrv.api.event.bus.EventPriority; import com.discordsrv.api.event.events.Event; /** * Indicates that DiscordSRV is shutting down. * <p> * DiscordSRV's own systems will shut down at the following times: * {@link EventPriority#EARLY}<br/> * - DiscordSRV's own modules shutdown<br/> * * {@link EventPriority#LATE}<br/> * - Discord connections are shutdown<br/> * * {@link EventPriority#LAST}<br/> * - DiscordSRV's scheduler is shutdown<br/> */ public class DiscordSRVShuttingDownEvent implements Event { }
1,849
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AccountLinkedEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/linking/AccountLinkedEvent.java
package com.discordsrv.api.event.events.linking; import com.discordsrv.api.event.events.Event; import com.discordsrv.api.profile.IProfile; import org.jetbrains.annotations.NotNull; import java.util.UUID; /** * An event for when an account pair has been linked successfully. */ public class AccountLinkedEvent implements Event { private final IProfile profile; public AccountLinkedEvent(@NotNull IProfile profile) { if (!profile.isLinked()) { throw new IllegalStateException("Profile is not linked"); } this.profile = profile; } /** * The profile of the linked account pair. * @return the profile */ @NotNull public IProfile getProfile() { return profile; } /** * The UUID of the player that was linked, this player may not be connected to the server at the time of this event. * @return the player's {@link UUID} */ @NotNull public UUID getPlayerUUID() { UUID uuid = profile.playerUUID(); if (uuid == null) { throw new IllegalStateException("playerUUID is null"); } return uuid; } /** * The user id of the user that was linked. * @return the user's Discord user id */ public long getUserId() { Long userId = profile.userId(); if (userId == null) { throw new IllegalStateException("userId is null"); } return userId; } }
1,463
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AccountUnlinkedEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/linking/AccountUnlinkedEvent.java
package com.discordsrv.api.event.events.linking; import com.discordsrv.api.event.events.Event; import org.jetbrains.annotations.NotNull; import java.util.UUID; /** * An event for when an account pair has been unlinked successfully. */ public class AccountUnlinkedEvent implements Event { private final UUID playerUUID; private final long userId; public AccountUnlinkedEvent(@NotNull UUID playerUUID, long userId) { this.playerUUID = playerUUID; this.userId = userId; } /** * The UUID of the player that was unlinked, this player may not be connected to the server at the time of this event. * @return the player's {@link UUID} */ @NotNull public UUID getPlayerUUID() { return playerUUID; } /** * The user id of the user that was unlinked. * @return the user's Discord user id */ public long getUserId() { return userId; } }
939
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordChatMessageCustomEmojiRenderEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/process/discord/DiscordChatMessageCustomEmojiRenderEvent.java
package com.discordsrv.api.event.events.message.process.discord; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.discord.entity.guild.DiscordCustomEmoji; import com.discordsrv.api.event.events.Event; import com.discordsrv.api.event.events.Processable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Renders a given {@link DiscordCustomEmoji} into a {@link MinecraftComponent} that can be displayed in Minecraft. * @see #process(MinecraftComponent) */ public class DiscordChatMessageCustomEmojiRenderEvent implements Event, Processable.Argument<MinecraftComponent> { private final DiscordCustomEmoji emoji; private MinecraftComponent rendered = null; public DiscordChatMessageCustomEmojiRenderEvent(@NotNull DiscordCustomEmoji emoji) { this.emoji = emoji; } @NotNull public DiscordCustomEmoji getEmoji() { return emoji; } /** * Gets the rendered representation of the emoji. * @return the rendered representation of the emoji if this event has been processed otherwise {@code null} */ @Nullable public MinecraftComponent getRenderedEmojiFromProcessing() { return rendered; } @Override public boolean isProcessed() { return rendered != null; } /** * Marks this event as processed, with the given {@link MinecraftComponent} being the representation of {@link DiscordCustomEmoji} in game. * @param renderedEmote the rendered emote */ @Override public void process(@NotNull MinecraftComponent renderedEmote) { if (rendered != null) { throw new IllegalStateException("Cannot process an already processed event"); } rendered = renderedEmote; } }
1,799
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordChatMessageProcessEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/process/discord/DiscordChatMessageProcessEvent.java
package com.discordsrv.api.event.events.message.process.discord; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessage; import com.discordsrv.api.event.events.Cancellable; import com.discordsrv.api.event.events.Processable; import com.discordsrv.api.event.events.message.receive.discord.DiscordChatMessageReceiveEvent; /** * Indicates that a Discord message is about to be processed, this will run once per {@link GameChannel} destination, * meaning it could run multiple times for a single Discord message. This runs after {@link DiscordChatMessageReceiveEvent}. */ public class DiscordChatMessageProcessEvent implements Cancellable, Processable.NoArgument { private final DiscordMessageChannel discordChannel; private final ReceivedDiscordMessage message; private String content; private final GameChannel destinationChannel; private boolean cancelled; private boolean processed; public DiscordChatMessageProcessEvent( DiscordMessageChannel discordChannel, ReceivedDiscordMessage message, GameChannel destinationChannel ) { this.discordChannel = discordChannel; this.message = message; this.content = message.getContent(); this.destinationChannel = destinationChannel; } public DiscordMessageChannel getDiscordChannel() { return discordChannel; } public ReceivedDiscordMessage getMessage() { return message; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public GameChannel getDestinationChannel() { return destinationChannel; } @Override public boolean isCancelled() { return cancelled; } @Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; } @Override public boolean isProcessed() { return processed; } @Override public void markAsProcessed() { if (cancelled) { throw new IllegalStateException("Cannot process cancelled event"); } if (processed) { throw new IllegalStateException("Cannot process already processed event"); } this.processed = true; } }
2,430
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
LeaveMessageReceiveEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/LeaveMessageReceiveEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.receive.game; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.player.DiscordSRVPlayer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Indicates that a leave message was received and will be processed * at {@link com.discordsrv.api.event.bus.EventPriority#DEFAULT} unless cancelled or processed by a 3rd party. */ public class LeaveMessageReceiveEvent extends AbstractGameMessageReceiveEvent { private final DiscordSRVPlayer player; private MinecraftComponent message; private GameChannel gameChannel; public LeaveMessageReceiveEvent( @Nullable Object triggeringEvent, @NotNull DiscordSRVPlayer player, @NotNull MinecraftComponent message, @Nullable GameChannel gameChannel, boolean cancelled) { super(triggeringEvent, cancelled); this.player = player; this.message = message; this.gameChannel = gameChannel; } @NotNull public DiscordSRVPlayer getPlayer() { return player; } @Nullable public MinecraftComponent getMessage() { return message; } public void setMessage(@Nullable MinecraftComponent message) { this.message = message; } @Nullable public GameChannel getGameChannel() { return gameChannel; } public void setGameChannel(@Nullable GameChannel gameChannel) { this.gameChannel = gameChannel; } }
2,853
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
JoinMessageReceiveEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/JoinMessageReceiveEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.receive.game; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.player.DiscordSRVPlayer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Indicates that a join message was received and will be processed * at {@link com.discordsrv.api.event.bus.EventPriority#DEFAULT} unless cancelled or processed by a 3rd party. */ public class JoinMessageReceiveEvent extends AbstractGameMessageReceiveEvent { private final DiscordSRVPlayer player; private MinecraftComponent message; private GameChannel gameChannel; private final boolean firstJoin; public JoinMessageReceiveEvent( @Nullable Object triggeringEvent, @NotNull DiscordSRVPlayer player, @Nullable MinecraftComponent message, @Nullable GameChannel gameChannel, boolean firstJoin, boolean cancelled) { super(triggeringEvent, cancelled); this.player = player; this.message = message; this.gameChannel = gameChannel; this.firstJoin = firstJoin; } @NotNull public DiscordSRVPlayer getPlayer() { return player; } @Nullable public MinecraftComponent getMessage() { return message; } public void setMessage(@Nullable MinecraftComponent message) { this.message = message; } @Nullable public GameChannel getGameChannel() { return gameChannel; } public void setGameChannel(@Nullable GameChannel gameChannel) { this.gameChannel = gameChannel; } public boolean isFirstJoin() { return firstJoin; } }
3,023
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AbstractGameMessageReceiveEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/AbstractGameMessageReceiveEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.receive.game; import com.discordsrv.api.event.events.Cancellable; import com.discordsrv.api.event.events.Processable; import org.jetbrains.annotations.Nullable; public abstract class AbstractGameMessageReceiveEvent implements Cancellable, Processable.NoArgument { private final Object triggeringEvent; private boolean cancelled; private boolean processed; public AbstractGameMessageReceiveEvent(@Nullable Object triggeringEvent, boolean cancelled) { this.triggeringEvent = triggeringEvent; this.cancelled = cancelled; } /** * Gets the event that triggered this event to occur. This varies depending on platform and different plugin integrations. * @return an event object, that isn't guaranteed to be of the same type every time, or {@code null} */ @Nullable public Object getTriggeringEvent() { return triggeringEvent; } @Override public boolean isCancelled() { return cancelled; } @Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; } @Override public boolean isProcessed() { return processed; } @Override public void markAsProcessed() { if (isCancelled()) { throw new IllegalStateException("Cannot process cancelled event"); } this.processed = true; } }
2,690
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DeathMessageReceiveEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/DeathMessageReceiveEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.receive.game; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.player.DiscordSRVPlayer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Indicates that a death message was received and will be processed * at {@link com.discordsrv.api.event.bus.EventPriority#DEFAULT} unless cancelled or processed by a 3rd party. */ public class DeathMessageReceiveEvent extends AbstractGameMessageReceiveEvent { private final DiscordSRVPlayer player; private MinecraftComponent message; private GameChannel gameChannel; public DeathMessageReceiveEvent( @NotNull Object triggeringEvent, @NotNull DiscordSRVPlayer player, @Nullable MinecraftComponent message, @Nullable GameChannel gameChannel, boolean cancelled) { super(triggeringEvent, cancelled); this.player = player; this.message = message; this.gameChannel = gameChannel; } @NotNull public DiscordSRVPlayer getPlayer() { return player; } @Nullable public MinecraftComponent getMessage() { return message; } public void setMessage(@Nullable MinecraftComponent message) { this.message = message; } @Nullable public GameChannel getGameChannel() { return gameChannel; } public void setGameChannel(@Nullable GameChannel gameChannel) { this.gameChannel = gameChannel; } }
2,852
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AwardMessageReceiveEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/AwardMessageReceiveEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.receive.game; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.player.DiscordSRVPlayer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Indicates that an advancement or achievement message was received will be processed * at {@link com.discordsrv.api.event.bus.EventPriority#DEFAULT} unless cancelled or processed by a 3rd party. */ public class AwardMessageReceiveEvent extends AbstractGameMessageReceiveEvent { private final DiscordSRVPlayer player; private MinecraftComponent name; private MinecraftComponent title; private GameChannel gameChannel; public AwardMessageReceiveEvent( @Nullable Object triggeringEvent, @NotNull DiscordSRVPlayer player, @Nullable MinecraftComponent name, @Nullable MinecraftComponent title, @Nullable GameChannel gameChannel, boolean cancelled ) { super(triggeringEvent, cancelled); this.player = player; this.name = name; this.title = title; this.gameChannel = gameChannel; } public DiscordSRVPlayer getPlayer() { return player; } @Nullable public MinecraftComponent getName() { return name; } public void setName(@Nullable MinecraftComponent name) { this.name = name; } @Nullable public MinecraftComponent getTitle() { return title; } public void setTitle(@Nullable MinecraftComponent title) { this.title = title; } public GameChannel getGameChannel() { return gameChannel; } public void setGameChannel(GameChannel gameChannel) { this.gameChannel = gameChannel; } }
3,107
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
GameChatMessageReceiveEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/GameChatMessageReceiveEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.receive.game; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.event.events.PlayerEvent; import com.discordsrv.api.player.DiscordSRVPlayer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Indicates that a chat message was received and will be processed * at {@link com.discordsrv.api.event.bus.EventPriority#DEFAULT} unless cancelled or processed by a 3rd party. */ public class GameChatMessageReceiveEvent extends AbstractGameMessageReceiveEvent implements PlayerEvent { private final DiscordSRVPlayer player; private MinecraftComponent message; private GameChannel gameChannel; public GameChatMessageReceiveEvent( @Nullable Object triggeringEvent, @NotNull DiscordSRVPlayer player, @NotNull MinecraftComponent message, @NotNull GameChannel gameChannel, boolean cancelled) { super(triggeringEvent, cancelled); this.player = player; this.message = message; this.gameChannel = gameChannel; } @NotNull public MinecraftComponent getMessage() { return message; } public void setMessage(@NotNull MinecraftComponent message) { this.message = message; } @NotNull public GameChannel getGameChannel() { return gameChannel; } public void setGameChannel(@NotNull GameChannel gameChannel) { this.gameChannel = gameChannel; } @Override public DiscordSRVPlayer getPlayer() { return player; } }
2,928
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
ServerSwitchMessageReceiveEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/ServerSwitchMessageReceiveEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.receive.game; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.player.DiscordSRVPlayer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Indicates that a server switch message was received and will be processed * at {@link com.discordsrv.api.event.bus.EventPriority#DEFAULT} unless cancelled or processed by a 3rd party. */ public class ServerSwitchMessageReceiveEvent extends AbstractGameMessageReceiveEvent { private final DiscordSRVPlayer player; private MinecraftComponent message; public ServerSwitchMessageReceiveEvent( @Nullable Object triggeringEvent, @NotNull DiscordSRVPlayer player, @Nullable MinecraftComponent message, boolean cancelled ) { super(triggeringEvent, cancelled); this.player = player; this.message = message; } @NotNull public DiscordSRVPlayer getPlayer() { return player; } @Nullable public MinecraftComponent getMessage() { return message; } public void setMessage(@Nullable MinecraftComponent message) { this.message = message; } }
2,503
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordChatMessageReceiveEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/receive/discord/DiscordChatMessageReceiveEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.receive.discord; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.channel.DiscordTextChannel; import com.discordsrv.api.discord.entity.channel.DiscordThreadChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuild; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessage; import com.discordsrv.api.event.events.Cancellable; import com.discordsrv.api.event.events.message.process.discord.DiscordChatMessageProcessEvent; import org.jetbrains.annotations.NotNull; /** * Indicates that a Discord message has been received and will be processed unless cancelled. * This runs once per Discord message, before {@link DiscordChatMessageProcessEvent}(s). */ public class DiscordChatMessageReceiveEvent implements Cancellable { private final ReceivedDiscordMessage message; private final DiscordMessageChannel channel; private boolean cancelled; public DiscordChatMessageReceiveEvent(@NotNull ReceivedDiscordMessage discordMessage, @NotNull DiscordMessageChannel channel) { this.message = discordMessage; this.channel = channel; if (!(channel instanceof DiscordTextChannel) && !(channel instanceof DiscordThreadChannel)) { throw new IllegalStateException("Cannot process messages that aren't from a text channel or thread"); } } public ReceivedDiscordMessage getMessage() { return message; } public DiscordMessageChannel getChannel() { return channel; } public DiscordGuild getGuild() { if (channel instanceof DiscordTextChannel) { return ((DiscordTextChannel) channel).getGuild(); } else if (channel instanceof DiscordThreadChannel) { return ((DiscordThreadChannel) channel).getParentChannel().getGuild(); } else { throw new IllegalStateException("Message isn't from a text channel or thread"); } } @Override public boolean isCancelled() { return cancelled; } @Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; } }
3,464
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
LeaveMessageForwardedEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/LeaveMessageForwardedEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.forward.game; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster; import org.jetbrains.annotations.NotNull; /** * Indicates that a leave message was forwarded to Discord. */ public class LeaveMessageForwardedEvent extends AbstractGameMessageForwardedEvent { public LeaveMessageForwardedEvent(@NotNull ReceivedDiscordMessageCluster discordMessage) { super(discordMessage); } }
1,734
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AbstractGameMessageForwardedEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/AbstractGameMessageForwardedEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.forward.game; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster; import com.discordsrv.api.event.events.Event; import org.jetbrains.annotations.NotNull; public abstract class AbstractGameMessageForwardedEvent implements Event { private final ReceivedDiscordMessageCluster discordMessage; public AbstractGameMessageForwardedEvent(@NotNull ReceivedDiscordMessageCluster discordMessage) { this.discordMessage = discordMessage; } /** * Gets the {@link ReceivedDiscordMessageCluster} containing the sent message(s). * @return the message cluster */ public ReceivedDiscordMessageCluster getDiscordMessage() { return discordMessage; } }
2,029
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
JoinMessageForwardedEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/JoinMessageForwardedEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.forward.game; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster; import org.jetbrains.annotations.NotNull; /** * Indicates that a join message was forwarded to Discord. */ public class JoinMessageForwardedEvent extends AbstractGameMessageForwardedEvent { public JoinMessageForwardedEvent(@NotNull ReceivedDiscordMessageCluster discordMessage) { super(discordMessage); } }
1,731
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DeathMessageForwardedEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/DeathMessageForwardedEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.forward.game; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster; import org.jetbrains.annotations.NotNull; /** * Indicates that a death message was forwarded to Discord. */ public class DeathMessageForwardedEvent extends AbstractGameMessageForwardedEvent { public DeathMessageForwardedEvent(@NotNull ReceivedDiscordMessageCluster discordMessage) { super(discordMessage); } }
1,734
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AwardMessageForwardedEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/AwardMessageForwardedEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.forward.game; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster; import org.jetbrains.annotations.NotNull; /** * Indicates that an advancement or achievement message was forwarded to Discord. */ public class AwardMessageForwardedEvent extends AbstractGameMessageForwardedEvent { public AwardMessageForwardedEvent(@NotNull ReceivedDiscordMessageCluster discordMessage) { super(discordMessage); } }
1,756
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
GameChatMessageForwardedEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/GameChatMessageForwardedEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.forward.game; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster; import org.jetbrains.annotations.NotNull; /** * Indicates that a chat message was forwarded to Discord. */ public class GameChatMessageForwardedEvent extends AbstractGameMessageForwardedEvent { public GameChatMessageForwardedEvent(@NotNull ReceivedDiscordMessageCluster discordMessage) { super(discordMessage); } }
1,739
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
ServerSwitchMessageForwardedEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/ServerSwitchMessageForwardedEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.forward.game; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster; import org.jetbrains.annotations.NotNull; /** * Indicates that a server switch message was forwarded to Discord. */ public class ServerSwitchMessageForwardedEvent extends AbstractGameMessageForwardedEvent { public ServerSwitchMessageForwardedEvent(@NotNull ReceivedDiscordMessageCluster discordMessage) { super(discordMessage); } }
1,756
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordChatMessageForwardedEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/message/forward/discord/DiscordChatMessageForwardedEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.message.forward.discord; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.event.events.Event; import org.jetbrains.annotations.NotNull; /** * Indicates that a message from Discord was forwarded to the provided {@link GameChannel}. */ public class DiscordChatMessageForwardedEvent implements Event { private final MinecraftComponent message; private final GameChannel channel; public DiscordChatMessageForwardedEvent(@NotNull MinecraftComponent message, @NotNull GameChannel channel) { this.message = message; this.channel = channel; } public MinecraftComponent getMessage() { return message; } public GameChannel getChannel() { return channel; } }
2,101
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
GameChannelLookupEvent.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/main/java/com/discordsrv/api/event/events/channel/GameChannelLookupEvent.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.event.events.channel; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.event.events.Processable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * This event is used to lookup {@link GameChannel}s by their name (and optionally plugin name). * This is also used to determine which plugin's channel should take priority when multiple plugins * define channels with the same name ({@link com.discordsrv.api.event.bus.EventPriority}). * * @see #isDefault() */ public class GameChannelLookupEvent implements Processable.Argument<GameChannel> { private final String pluginName; private final String channelName; private boolean processed; private GameChannel channel; public GameChannelLookupEvent(@Nullable String pluginName, @NotNull String channelName) { this.pluginName = pluginName; this.channelName = channelName; } /** * If this is {@code true} the default channel should be returned, if it exists. * @return if this lookup is for the default channel */ public boolean isDefault() { return GameChannel.DEFAULT_NAME.equals(channelName); } /** * The channel name being looked up, this should be case-insensitive wherever possible. * @return the channel name */ @NotNull public String getChannelName() { return channelName; } /** * Returns the channel from a {@link #process(GameChannel)} matching required criteria. * @return the game channel provided by a listener * @throws IllegalStateException if {@link #isProcessed()} doesn't return true */ @NotNull public GameChannel getChannelFromProcessing() { if (!processed) { throw new IllegalStateException("This event has not been successfully processed yet, no channel is available"); } return channel; } @Override public boolean isProcessed() { return processed; } /** * Provides a {@link GameChannel} for the provided channel name ({@link #getChannelName()}). * If this is the {@link #isDefault()} channel, any channel name is accepted. * @param channel the channel * @throws IllegalStateException if the event is already processed * @throws IllegalArgumentException if the provided channel doesn't match {@link #getChannelName()} and {@link #isDefault()} is {@code false} */ @Override public void process(@NotNull GameChannel channel) { if (processed) { throw new IllegalStateException("Already processed"); } if (pluginName != null && !pluginName.equalsIgnoreCase(channel.getOwnerName())) { // Not the plugin we're looking for, ignore return; } String channelName = channel.getChannelName(); if (!isDefault() && !channelName.equalsIgnoreCase(this.channelName)) { throw new IllegalArgumentException("The provided channel is named " + channelName + " when it should've been: " + this.channelName); } this.channel = channel; this.processed = true; } }
4,464
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
SubscribeProcessor.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/api/src/ap/java/com/discordsrv/api/processor/SubscribeProcessor.java
/* * This file is part of the DiscordSRV API, licensed under the MIT License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.discordsrv.api.processor; import com.discordsrv.api.event.bus.Subscribe; import javax.annotation.processing.*; import javax.lang.model.SourceVersion; import javax.lang.model.element.*; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.Elements; import javax.lang.model.util.Types; import java.util.List; import java.util.Set; import static javax.tools.Diagnostic.Kind.ERROR; /** * Annotation processor for {@link Subscribe}, gives a error during compilation if a given listener method is wrong. */ @SupportedAnnotationTypes(SubscribeProcessor.SUBSCRIBE_CLASS_NAME) @SupportedSourceVersion(SourceVersion.RELEASE_8) public class SubscribeProcessor extends AbstractProcessor { protected static final String SUBSCRIBE_CLASS_NAME = "com.discordsrv.api.event.bus.Subscribe"; protected static final String EVENT_CLASS_NAME = "com.discordsrv.api.event.events.Event"; protected static final String JDA_EVENT_CLASS_NAME = "net.dv8tion.jda.api.events.GenericEvent"; @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { Elements elements = processingEnv.getElementUtils(); Types types = processingEnv.getTypeUtils(); TypeMirror eventMirror = types.getDeclaredType(elements.getTypeElement(EVENT_CLASS_NAME)); TypeMirror jdaEventMirror = types.getDeclaredType(elements.getTypeElement(JDA_EVENT_CLASS_NAME)); TypeElement subscribeType = elements.getTypeElement(SUBSCRIBE_CLASS_NAME); boolean hasAnnotation = false; for (TypeElement annotation : annotations) { if (annotation.equals(subscribeType)) { hasAnnotation = true; break; } } if (!hasAnnotation) { return false; } for (Element element : roundEnv.getElementsAnnotatedWith(Subscribe.class)) { Messager messager = processingEnv.getMessager(); if (element.getKind() != ElementKind.METHOD) { messager.printMessage(ERROR, "@Subscribe can only be used on methods", element); continue; } ExecutableElement method = (ExecutableElement) element; if (method.getEnclosingElement().getKind().isInterface()) { messager.printMessage(ERROR, "Cannot be used on interfaces", element); } if (method.getReturnType().getKind() != TypeKind.VOID) { messager.printMessage(ERROR, "Must return void", element); } Set<Modifier> modifiers = method.getModifiers(); if (!modifiers.contains(Modifier.PUBLIC)) { messager.printMessage(ERROR, "Must be public", element); } if (modifiers.contains(Modifier.STATIC)) { messager.printMessage(ERROR, "Must not be static", element); } if (modifiers.contains(Modifier.ABSTRACT)) { messager.printMessage(ERROR, "Cannot be abstract", element); } List<? extends VariableElement> parameters = method.getParameters(); if (parameters.isEmpty()) { messager.printMessage(ERROR, "Method doesn't have a DiscordSRV or JDA event as the only parameter", element); continue; } if (parameters.size() > 1) { messager.printMessage(ERROR, "Method should only have the DiscordSRV or JDA event as a parameter", element); } TypeMirror firstParameter = parameters.get(0).asType(); if (!types.isAssignable(firstParameter, eventMirror) && !types.isAssignable(firstParameter, jdaEventMirror)) { messager.printMessage(ERROR, "First argument is not a DiscordSRV or JDA event", element); } } return false; } }
5,177
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AbstractBukkitAwardListener.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/AbstractBukkitAwardListener.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.listener.award; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.logging.Logger; import com.discordsrv.common.logging.NamedLogger; import org.bukkit.event.Listener; public abstract class AbstractBukkitAwardListener implements Listener { protected final Logger logger; protected final IBukkitAwardForwarder forwarder; public AbstractBukkitAwardListener(DiscordSRV discordSRV, IBukkitAwardForwarder forwarder) { this.logger = new NamedLogger(discordSRV, "AWARD_LISTENER"); this.forwarder = forwarder; } }
1,420
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitLegacyAdvancementListener.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/BukkitLegacyAdvancementListener.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.listener.award; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.component.util.ComponentUtil; import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer; import org.bukkit.Bukkit; import org.bukkit.advancement.Advancement; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerAdvancementDoneEvent; import java.lang.reflect.Method; import java.util.Arrays; /** * Used for Spigot and Paper in versions before they added advancement apis. */ public class BukkitLegacyAdvancementListener extends AbstractBukkitAwardListener { private final NMS nms; public BukkitLegacyAdvancementListener(DiscordSRV discordSRV, IBukkitAwardForwarder forwarder) { super(discordSRV, forwarder); String version = Bukkit.getServer().getBukkitVersion().split("-", 2)[0]; NMS nms = null; try { if ((version.startsWith("1.19") && !version.matches("1.19.[1-3].*")) || version.startsWith("1.2")) { // 1.19.4+ nms = new NMS("org.bukkit.craftbukkit." + version + ".advancement.CraftAdvancement", "d", "i", "a"); } else { // <1.19.4 nms = new NMS("org.bukkit.craftbukkit." + version + ".advancement.CraftAdvancement", "c", "i", "a"); } } catch (Throwable t) { logger.error("Could not get NMS methods for advancements."); logger.debug(t); } this.nms = nms; } @EventHandler(priority = EventPriority.MONITOR) public void onPlayerAdvancementDone(PlayerAdvancementDoneEvent event) { if (nms == null) { return; } try { ReturnData data = nms.getData(event.getAdvancement()); if (data == null) { return; } forwarder.publishEvent( event, event.getPlayer(), data.titleJson != null ? ComponentUtil.toAPI(BukkitComponentSerializer.gson().deserialize(data.titleJson)) : null, null, false); } catch (ReflectiveOperationException e) { logger.debug("Failed to get advancement data", e); } } private static class NMS { private final Method handleMethod; private final Method advancementDisplayMethod; private final Method broadcastToChatMethod; private final Method titleMethod; private final Method toJsonMethod; public NMS( String craftAdvancementClassName, String displayMethodName, String broadcastToChatMethodName, String titleMethodName ) throws ReflectiveOperationException { Class<?> clazz = Class.forName(craftAdvancementClassName); handleMethod = clazz.getDeclaredMethod("getHandle"); Class<?> nmsClass = handleMethod.getReturnType(); advancementDisplayMethod = nmsClass.getDeclaredMethod(displayMethodName); Class<?> displayClass = advancementDisplayMethod.getReturnType(); broadcastToChatMethod = displayClass.getDeclaredMethod(broadcastToChatMethodName); titleMethod = displayClass.getDeclaredMethod(titleMethodName); Class<?> serializer = Class.forName(titleMethod.getReturnType().getName() + "$ChatSerializer"); toJsonMethod = Arrays.stream(serializer.getDeclaredMethods()) .filter(method -> method.getReturnType().equals(String.class)) .findAny().orElseThrow(() -> new NoSuchMethodException("ChatSerializer toJson")); } public ReturnData getData(Advancement advancement) throws ReflectiveOperationException { Object nms = handleMethod.invoke(advancement); Object display = advancementDisplayMethod.invoke(nms); if (display == null) { // Not something that would be displayed in chat return null; } boolean broadcastToChat = (boolean) broadcastToChatMethod.invoke(display); if (!broadcastToChat) { // Not something that would be displayed in chat return null; } Object titleChat = titleMethod.invoke(display); return new ReturnData( toJson(titleChat) ); } private String toJson(Object chat) throws ReflectiveOperationException { return (String) toJsonMethod.invoke(null, chat); } } private static class ReturnData { private final String titleJson; public ReturnData(String titleJson) { this.titleJson = titleJson; } } }
5,759
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
IBukkitAwardForwarder.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/IBukkitAwardForwarder.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.listener.award; import com.discordsrv.api.component.MinecraftComponent; import org.bukkit.entity.Player; public interface IBukkitAwardForwarder { void publishEvent(Object triggeringEvent, Player player, MinecraftComponent name, MinecraftComponent message, boolean cancelled); }
1,144
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
SpigotModernAdvancementListener.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/spigot/src/main/java/com/discordsrv/bukkit/listener/award/SpigotModernAdvancementListener.java
package com.discordsrv.bukkit.listener.award; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.component.util.ComponentUtil; import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer; import org.bukkit.advancement.Advancement; import org.bukkit.advancement.AdvancementDisplay; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerAdvancementDoneEvent; public class SpigotModernAdvancementListener extends AbstractBukkitAwardListener { public SpigotModernAdvancementListener(DiscordSRV discordSRV, IBukkitAwardForwarder forwarder) { super(discordSRV, forwarder); } @EventHandler(priority = EventPriority.MONITOR) public void onPlayerAdvancementDone(PlayerAdvancementDoneEvent event) { Advancement advancement = event.getAdvancement(); AdvancementDisplay display = advancement.getDisplay(); if (display == null || !display.shouldAnnounceChat()) { logger.trace("Skipping advancement display of \"" + advancement.getKey().getKey() + "\" for " + event.getPlayer() + ": advancement display == null or does not broadcast to chat"); return; } MinecraftComponent title = ComponentUtil.toAPI(BukkitComponentSerializer.legacy().deserialize(display.getTitle())) ; forwarder.publishEvent(event, event.getPlayer(), title, null, false); } }
1,513
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
SpigotPlayer.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/spigot/src/main/java/com/discordsrv/bukkit/player/SpigotPlayer.java
package com.discordsrv.bukkit.player; import com.discordsrv.common.player.provider.model.SkinInfo; import org.bukkit.entity.Player; import org.bukkit.profile.PlayerTextures; import java.net.URL; import java.util.Locale; public final class SpigotPlayer { private SpigotPlayer() {} private static final boolean playerProfileExists; static { Class<?> playerClass = Player.class; boolean playerProfile = false; try { playerClass.getMethod("getPlayerProfile"); playerProfile = true; } catch (ReflectiveOperationException ignored) {} playerProfileExists = playerProfile; } public static SkinInfo getSkinInfo(Player player) { if (!playerProfileExists) { return null; } PlayerTextures textures = player.getPlayerProfile().getTextures(); URL skinUrl = textures.getSkin(); if (skinUrl == null) { return null; } String skinUrlPlain = skinUrl.toString(); return new SkinInfo( skinUrlPlain.substring(skinUrlPlain.lastIndexOf('/') + 1), textures.getSkinModel().toString().toLowerCase(Locale.ROOT) ); } }
1,217
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordSRVBukkitLoader.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/loader/src/main/java/com/discordsrv/bukkit/loader/DiscordSRVBukkitLoader.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.loader; import dev.vankka.dependencydownload.jarinjar.loader.exception.LoadingException; import dev.vankka.mcdependencydownload.bukkit.loader.BukkitLoader; import org.jetbrains.annotations.NotNull; import java.net.URL; import java.util.logging.Level; @SuppressWarnings("unused") // Used by Bukkit public class DiscordSRVBukkitLoader extends BukkitLoader { @Override public @NotNull String getBootstrapClassName() { return "com.discordsrv.bukkit.DiscordSRVBukkitBootstrap"; } @Override public @NotNull URL getJarInJarResource() { URL resource = getClassLoader().getResource("bukkit.jarinjar"); if (resource == null) { throw new IllegalStateException("Jar does not contain jarinjar"); } return resource; } @Override public void handleLoadingException(LoadingException exception) { getLogger().logp(Level.SEVERE, null, null, exception.getCause(), exception::getMessage); } }
1,834
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
IBukkitScheduler.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/folia/src/main/java/com/discordsrv/bukkit/scheduler/IBukkitScheduler.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.scheduler; import com.discordsrv.common.scheduler.ServerScheduler; import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.plugin.Plugin; import java.util.function.BiConsumer; public interface IBukkitScheduler extends ServerScheduler { void runWithArgs(BiConsumer<Server, Plugin> runNormal); default void runOnMainThread(CommandSender sender, Runnable task) { runOnMainThread(task); } }
1,302
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
IFoliaScheduler.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/folia/src/main/java/com/discordsrv/bukkit/scheduler/IFoliaScheduler.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.scheduler; import com.discordsrv.common.scheduler.ServerScheduler; import org.bukkit.command.BlockCommandSender; import org.bukkit.command.CommandSender; import org.bukkit.command.ProxiedCommandSender; import org.bukkit.entity.Entity; public interface IFoliaScheduler extends ServerScheduler, IBukkitScheduler { @Override default void runOnMainThread(CommandSender sender, Runnable task) { if (sender instanceof ProxiedCommandSender) { runOnMainThread(((ProxiedCommandSender) sender).getCallee(), task); return; } if (sender instanceof Entity) { runWithArgs((server, plugin) -> ((Entity) sender).getScheduler().run( plugin, r -> task.run(), null )); } else if (sender instanceof BlockCommandSender) { runWithArgs((server, plugin) -> server.getRegionScheduler().run( plugin, ((BlockCommandSender) sender).getBlock().getLocation(), r -> task.run() )); } else { runOnMainThread(task); } } @Override default void runOnMainThread(Runnable task) { runWithArgs((server, plugin) -> server.getGlobalRegionScheduler().execute(plugin, task)); } @Override default void runOnMainThreadLaterInTicks(Runnable task, int ticks) { runWithArgs((server, plugin) -> server.getGlobalRegionScheduler().runDelayed(plugin, r -> task.run(), ticks)); } @Override default void runOnMainThreadAtFixedRateInTicks(Runnable task, int initialTicks, int rateTicks) { runWithArgs((server, plugin) -> server.getGlobalRegionScheduler().execute(plugin, task)); } }
2,618
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitDiscordSRV.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit; import com.discordsrv.api.DiscordSRVApi; import com.discordsrv.bukkit.ban.BukkitBanModule; import com.discordsrv.bukkit.command.game.BukkitGameCommandExecutionHelper; import com.discordsrv.bukkit.command.game.handler.AbstractBukkitCommandHandler; import com.discordsrv.bukkit.component.translation.BukkitTranslationLoader; import com.discordsrv.bukkit.config.connection.BukkitConnectionConfig; import com.discordsrv.bukkit.config.main.BukkitConfig; import com.discordsrv.bukkit.config.manager.BukkitConfigManager; import com.discordsrv.bukkit.config.manager.BukkitConnectionConfigManager; import com.discordsrv.bukkit.config.manager.BukkitMessagesConfigManager; import com.discordsrv.bukkit.console.BukkitConsole; import com.discordsrv.bukkit.listener.BukkitConnectionListener; import com.discordsrv.bukkit.listener.BukkitDeathListener; import com.discordsrv.bukkit.listener.BukkitRequiredLinkingListener; import com.discordsrv.bukkit.listener.BukkitStatusMessageListener; import com.discordsrv.bukkit.listener.award.BukkitAwardForwarder; import com.discordsrv.bukkit.listener.chat.BukkitChatForwarder; import com.discordsrv.bukkit.player.BukkitPlayerProvider; import com.discordsrv.bukkit.plugin.BukkitPluginManager; import com.discordsrv.bukkit.requiredlinking.BukkitRequiredLinkingModule; import com.discordsrv.bukkit.scheduler.BukkitScheduler; import com.discordsrv.bukkit.scheduler.FoliaScheduler; import com.discordsrv.bukkit.scheduler.IBukkitScheduler; import com.discordsrv.common.ServerDiscordSRV; import com.discordsrv.common.command.game.handler.ICommandHandler; import com.discordsrv.common.config.configurate.manager.ConnectionConfigManager; import com.discordsrv.common.config.configurate.manager.MainConfigManager; import com.discordsrv.common.config.configurate.manager.MessagesConfigManager; import com.discordsrv.common.config.messages.MessagesConfig; import com.discordsrv.common.debug.data.OnlineMode; import com.discordsrv.common.messageforwarding.game.minecrafttodiscord.MinecraftToDiscordChatModule; import com.discordsrv.common.plugin.PluginManager; import net.kyori.adventure.platform.bukkit.BukkitAudiences; import org.bukkit.Server; import org.bukkit.plugin.ServicePriority; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; import java.util.List; import java.util.Set; public class BukkitDiscordSRV extends ServerDiscordSRV<DiscordSRVBukkitBootstrap, BukkitConfig, BukkitConnectionConfig, MessagesConfig> { private BukkitAudiences audiences; private BukkitTranslationLoader translationLoader; private final IBukkitScheduler scheduler; private final BukkitConsole console; private final BukkitPlayerProvider playerProvider; private final BukkitPluginManager pluginManager; private AbstractBukkitCommandHandler commandHandler; private final BukkitRequiredLinkingListener requiredLinkingListener; private final BukkitGameCommandExecutionHelper autoCompleteHelper; private final BukkitConnectionConfigManager connectionConfigManager; private final BukkitConfigManager configManager; private final BukkitMessagesConfigManager messagesConfigManager; private static IBukkitScheduler createScheduler(BukkitDiscordSRV discordSRV) { try { Class.forName("io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler"); return new FoliaScheduler(discordSRV); } catch (ClassNotFoundException ignored) { return new BukkitScheduler(discordSRV); } } public BukkitDiscordSRV(DiscordSRVBukkitBootstrap bootstrap) { super(bootstrap); this.scheduler = createScheduler(this); this.console = new BukkitConsole(this); this.playerProvider = new BukkitPlayerProvider(this); this.pluginManager = new BukkitPluginManager(this); // Config this.connectionConfigManager = new BukkitConnectionConfigManager(this); this.configManager = new BukkitConfigManager(this); this.messagesConfigManager = new BukkitMessagesConfigManager(this); load(); this.requiredLinkingListener = new BukkitRequiredLinkingListener(this); this.autoCompleteHelper = new BukkitGameCommandExecutionHelper(this); } public JavaPlugin plugin() { return bootstrap.getPlugin(); } public Server server() { return plugin().getServer(); } public BukkitAudiences audiences() { return audiences; } @Override public IBukkitScheduler scheduler() { return scheduler; } @Override public BukkitConsole console() { return console; } @Override public @NotNull BukkitPlayerProvider playerProvider() { return playerProvider; } @Override public PluginManager pluginManager() { return pluginManager; } @Override public OnlineMode onlineMode() { try { Class<?> paperConfig = Class.forName("com.destroystokyo.paper.PaperConfig"); Field velocitySupport = paperConfig.getField("velocitySupport"); Field velocityOnlineMode = paperConfig.getField("velocityOnlineMode"); if (velocitySupport.getBoolean(null) && velocityOnlineMode.getBoolean(null)) { return OnlineMode.VELOCITY; } } catch (Throwable ignored) {} try { Class<?> spigotConfig = Class.forName("org.spigotmc.SpigotConfig"); Field bungee = spigotConfig.getField("bungee"); if (bungee.getBoolean(null)) { return OnlineMode.BUNGEE; } } catch (Throwable ignored) {} return OnlineMode.of(server().getOnlineMode()); } @Override public ICommandHandler commandHandler() { return commandHandler; } @Override public ConnectionConfigManager<BukkitConnectionConfig> connectionConfigManager() { return connectionConfigManager; } @Override public MainConfigManager<BukkitConfig> configManager() { return configManager; } @Override public MessagesConfigManager<MessagesConfig> messagesConfigManager() { return messagesConfigManager; } @Override protected void enable() throws Throwable { // Service provider server().getServicesManager().register(DiscordSRVApi.class, this, plugin(), ServicePriority.Normal); // Adventure related stuff this.audiences = BukkitAudiences.create(bootstrap.getPlugin()); this.translationLoader = new BukkitTranslationLoader(this); // Command handler commandHandler = AbstractBukkitCommandHandler.get(this); // Modules registerModule(MinecraftToDiscordChatModule::new); registerModule(BukkitRequiredLinkingModule::new); registerModule(BukkitBanModule::new); // Integrations registerIntegration("com.discordsrv.bukkit.integration.VaultIntegration"); registerIntegration("com.discordsrv.bukkit.integration.PlaceholderAPIIntegration"); registerIntegration("com.discordsrv.bukkit.integration.EssentialsXIntegration"); // Chat Integrations registerIntegration("com.discordsrv.bukkit.integration.chat.ChattyChatIntegration"); registerIntegration("com.discordsrv.bukkit.integration.chat.GriefPreventionChatIntegration"); registerIntegration("com.discordsrv.bukkit.integration.chat.LunaChatIntegration"); registerIntegration("com.discordsrv.bukkit.integration.chat.McMMOChatIntegration"); registerIntegration("com.discordsrv.bukkit.integration.chat.TownyChatIntegration"); registerIntegration("com.discordsrv.bukkit.integration.chat.VentureChatIntegration"); super.enable(); // Register listeners server().getPluginManager().registerEvents(BukkitAwardForwarder.get(this), plugin()); server().getPluginManager().registerEvents(BukkitChatForwarder.get(this), plugin()); server().getPluginManager().registerEvents(new BukkitDeathListener(this), plugin()); server().getPluginManager().registerEvents(new BukkitStatusMessageListener(this), plugin()); // Connection listener server().getPluginManager().registerEvents(new BukkitConnectionListener(this), plugin()); } @Override public List<ReloadResult> reload(Set<ReloadFlag> flags, boolean initial) throws Throwable { List<ReloadResult> results = super.reload(flags, initial); if (flags.contains(ReloadFlag.TRANSLATIONS)) { translationLoader.reload(); } return results; } @Override protected void disable() { super.disable(); requiredLinkingListener.disable(); audiences.close(); } @Override public BukkitGameCommandExecutionHelper executeHelper() { return autoCompleteHelper; } }
9,791
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
DiscordSRVBukkitBootstrap.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/DiscordSRVBukkitBootstrap.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit; import com.discordsrv.common.bootstrap.IBootstrap; import com.discordsrv.common.bootstrap.LifecycleManager; import com.discordsrv.common.logging.Logger; import com.discordsrv.common.logging.backend.impl.JavaLoggerImpl; import dev.vankka.dependencydownload.classpath.ClasspathAppender; import dev.vankka.dependencydownload.jarinjar.classloader.JarInJarClassLoader; import dev.vankka.mcdependencydownload.bukkit.bootstrap.BukkitBootstrap; import org.bukkit.plugin.java.JavaPlugin; import java.io.IOException; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; public class DiscordSRVBukkitBootstrap extends BukkitBootstrap implements IBootstrap { private final Logger logger; private final LifecycleManager lifecycleManager; private BukkitDiscordSRV discordSRV; private final List<Runnable> mainThreadTasksForDisable = new ArrayList<>(); // Don't change these parameters public DiscordSRVBukkitBootstrap(JarInJarClassLoader classLoader, JavaPlugin plugin) throws IOException { super(classLoader, plugin); this.logger = new JavaLoggerImpl(plugin.getLogger()); this.lifecycleManager = new LifecycleManager( logger, plugin.getDataFolder().toPath(), getDependencyResources(), getClasspathAppender() ); } private static String[] getDependencyResources() { List<String> resources = new ArrayList<>(); resources.add("dependencies/runtimeDownload-bukkit.txt"); try { Class.forName("com.mojang.brigadier.CommandDispatcher"); resources.add("dependencies/commodore.txt"); } catch (ClassNotFoundException ignored) { // CommandDispatcher not present, don't need to bother downloading commodore } return resources.toArray(new String[0]); } @Override public void onEnable() { lifecycleManager.loadAndEnable(() -> this.discordSRV = new BukkitDiscordSRV(this)); boolean isFolia = false; try { Class.forName("io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler"); isFolia = true; } catch (ClassNotFoundException ignored) {} if (isFolia) { if (discordSRV != null) { discordSRV.invokeServerStarted(); } return; } // Run a task on the main thread 1 tick later, so essentially when the server has finished booting getPlugin().getServer().getScheduler().runTaskLater(getPlugin(), () -> { if (discordSRV != null) { discordSRV.invokeServerStarted(); } }, 1L); } @Override public void onDisable() { lifecycleManager.disable(discordSRV); // Run tasks on the main thread (scheduler cannot be used when disabling) for (Runnable runnable : mainThreadTasksForDisable) { runnable.run(); } } @Override public Logger logger() { return logger; } @Override public ClasspathAppender classpathAppender() { return getClasspathAppender(); } @Override public ClassLoader classLoader() { return getClassLoader(); } @Override public LifecycleManager lifecycleManager() { return lifecycleManager; } @Override public Path dataDirectory() { return getPlugin().getDataFolder().toPath(); } public List<Runnable> mainThreadTasksForDisable() { return mainThreadTasksForDisable; } }
4,439
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitRequiredLinkingModule.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/requiredlinking/BukkitRequiredLinkingModule.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.requiredlinking; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.config.main.BukkitRequiredLinkingConfig; import com.discordsrv.common.linking.requirelinking.ServerRequireLinkingModule; import org.bukkit.event.Listener; public class BukkitRequiredLinkingModule extends ServerRequireLinkingModule<BukkitDiscordSRV> implements Listener { public BukkitRequiredLinkingModule(BukkitDiscordSRV discordSRV) { super(discordSRV); } @Override public BukkitRequiredLinkingConfig config() { return discordSRV.config().requiredLinking; } }
1,455
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitStatusMessageListener.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitStatusMessageListener.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.listener; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.event.events.message.receive.game.JoinMessageReceiveEvent; import com.discordsrv.api.event.events.message.receive.game.LeaveMessageReceiveEvent; import com.discordsrv.api.player.DiscordSRVPlayer; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.component.PaperComponentHandle; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; public class BukkitStatusMessageListener implements Listener { private static final PaperComponentHandle<PlayerJoinEvent> JOIN_HANDLE; private static final PaperComponentHandle<PlayerQuitEvent> QUIT_HANDLE; static { JOIN_HANDLE = new PaperComponentHandle<>( PlayerJoinEvent.class, "joinMessage", PlayerJoinEvent::getJoinMessage ); QUIT_HANDLE = new PaperComponentHandle<>( PlayerQuitEvent.class, "quitMessage", PlayerQuitEvent::getQuitMessage ); } private final BukkitDiscordSRV discordSRV; public BukkitStatusMessageListener(BukkitDiscordSRV discordSRV) { this.discordSRV = discordSRV; } @EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(PlayerJoinEvent event) { DiscordSRVPlayer player = discordSRV.playerProvider().player(event.getPlayer()); MinecraftComponent component = JOIN_HANDLE.getComponent(event); boolean firstJoin = !event.getPlayer().hasPlayedBefore(); discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( new JoinMessageReceiveEvent(event, player, component, null, firstJoin, false) )); } @EventHandler(priority = EventPriority.HIGH) public void onPlayerQuit(PlayerQuitEvent event) { DiscordSRVPlayer player = discordSRV.playerProvider().player(event.getPlayer()); MinecraftComponent component = QUIT_HANDLE.getComponent(event); discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( new LeaveMessageReceiveEvent(event, player, component, null, false) )); } }
3,183
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitRequiredLinkingListener.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitRequiredLinkingListener.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.listener; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.config.main.BukkitRequiredLinkingConfig; import com.discordsrv.bukkit.requiredlinking.BukkitRequiredLinkingModule; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.component.util.ComponentUtil; import com.discordsrv.common.config.main.linking.ServerRequiredLinkingConfig; import com.discordsrv.common.linking.LinkStore; import com.discordsrv.common.player.IPlayer; import com.github.benmanes.caffeine.cache.Cache; import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer; import net.kyori.adventure.text.Component; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.*; import org.bukkit.event.player.*; import java.util.Map; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Supplier; public class BukkitRequiredLinkingListener implements Listener { private final BukkitDiscordSRV discordSRV; private final Cache<UUID, Boolean> linkCheckRateLimit; public BukkitRequiredLinkingListener(BukkitDiscordSRV discordSRV) { this.discordSRV = discordSRV; this.linkCheckRateLimit = discordSRV.caffeineBuilder() .expireAfterWrite(LinkStore.LINKING_CODE_RATE_LIMIT) .build(); register(PlayerLoginEvent.class, this::handle); register(AsyncPlayerPreLoginEvent.class, this::handle); discordSRV.server().getPluginManager().registerEvents(this, discordSRV.plugin()); } @SuppressWarnings("unchecked") private <T extends Event> void register(Class<T> eventType, BiConsumer<T, EventPriority> eventConsumer) { for (EventPriority priority : EventPriority.values()) { if (priority == EventPriority.MONITOR) { continue; } discordSRV.server().getPluginManager().registerEvent( eventType, this, priority, (listener, event) -> eventConsumer.accept((T) event, priority), discordSRV.plugin(), true ); } } public void disable() { HandlerList.unregisterAll(this); } private BukkitRequiredLinkingModule getModule() { int tries = 0; BukkitRequiredLinkingModule module; do { module = discordSRV.getModule(BukkitRequiredLinkingModule.class); try { Thread.sleep(100); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } tries++; } while (module == null || tries >= 50); return module; } private CompletableFuture<Component> getBlockReason(UUID playerUUID, String playerName, boolean join) { BukkitRequiredLinkingModule module = getModule(); if (module == null) { Component message = ComponentUtil.fromAPI( discordSRV.messagesConfig().minecraft.unableToLinkAtThisTime.textBuilder().build() ); return CompletableFuture.completedFuture(message); } return module.getBlockReason(playerUUID, playerName, join); } // // Kick // private void handle(AsyncPlayerPreLoginEvent event, EventPriority priority) { handle( "AsyncPlayerPreLoginEvent", priority, event.getUniqueId(), event.getName(), () -> event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED ? event.getLoginResult().name() : null, text -> event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, text) ); } private void handle(PlayerLoginEvent event, EventPriority priority) { Player player = event.getPlayer(); handle( "PlayerLoginEvent", priority, player.getUniqueId(), player.getName(), () -> event.getResult() != PlayerLoginEvent.Result.ALLOWED ? event.getResult().name() : null, text -> event.disallow(PlayerLoginEvent.Result.KICK_OTHER, text) ); } private void handle( String eventType, EventPriority priority, UUID playerUUID, String playerName, Supplier<String> alreadyBlocked, Consumer<String> disallow ) { BukkitRequiredLinkingConfig config = discordSRV.config().requiredLinking; if (!config.enabled || config.action != ServerRequiredLinkingConfig.Action.KICK || !eventType.equals(config.kick.event) || !priority.name().equals(config.kick.priority)) { return; } String blockType = alreadyBlocked.get(); if (blockType != null) { discordSRV.logger().debug(playerName + " is already blocked for " + eventType + "/" + priority + " (" + blockType + ")"); return; } Component kickReason = getBlockReason(playerUUID, playerName, true).join(); if (kickReason != null) { disallow.accept(BukkitComponentSerializer.legacy().serialize(kickReason)); } } // // Freeze // private final Map<UUID, Component> frozen = new ConcurrentHashMap<>(); private boolean isFrozen(Player player) { return frozen.containsKey(player.getUniqueId()); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPreLogin(AsyncPlayerPreLoginEvent event) { if (event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) { return; } if (discordSRV.isShutdown()) { return; } else if (!discordSRV.isReady()) { try { discordSRV.waitForStatus(DiscordSRV.Status.CONNECTED); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } BukkitRequiredLinkingConfig config = discordSRV.config().requiredLinking; if (!config.enabled || config.action != ServerRequiredLinkingConfig.Action.FREEZE) { return; } Component blockReason = getBlockReason(event.getUniqueId(), event.getName(), false).join(); if (blockReason != null) { frozen.put(event.getUniqueId(), blockReason); } } @EventHandler(priority = EventPriority.MONITOR) public void onLogin(PlayerLoginEvent event) { if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) { frozen.remove(event.getPlayer().getUniqueId()); } } @EventHandler(priority = EventPriority.MONITOR) public void onJoin(PlayerJoinEvent event) { UUID uuid = event.getPlayer().getUniqueId(); Component blockReason = frozen.get(uuid); if (blockReason == null) { return; } IPlayer player = discordSRV.playerProvider().player(uuid); if (player == null) { throw new IllegalStateException("Player not available: " + uuid); } player.sendMessage(blockReason); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerMove(PlayerMoveEvent event) { Component freezeReason = frozen.get(event.getPlayer().getUniqueId()); if (freezeReason == null) { return; } Location from = event.getFrom(), to = event.getTo(); if (from.getWorld().getName().equals(to.getWorld().getName()) && from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ() && from.getBlockY() >= to.getBlockY()) { return; } event.setTo( new Location( from.getWorld(), from.getBlockX() + 0.5, from.getBlockY(), from.getBlockZ() + 0.5, from.getYaw(), from.getPitch() ) ); IPlayer player = discordSRV.playerProvider().player(event.getPlayer()); player.sendMessage(freezeReason); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerChat(AsyncPlayerChatEvent event) { Component freezeReason = frozen.get(event.getPlayer().getUniqueId()); if (freezeReason == null) { event.getRecipients().removeIf(this::isFrozen); return; } event.setCancelled(true); IPlayer player = discordSRV.playerProvider().player(event.getPlayer()); player.sendMessage(freezeReason); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommand(PlayerCommandPreprocessEvent event) { if (!isFrozen(event.getPlayer())) { return; } event.setCancelled(true); String message = event.getMessage(); if (message.startsWith("/")) message = message.substring(1); if (message.equals("discord link") || message.equals("link")) { IPlayer player = discordSRV.playerProvider().player(event.getPlayer()); if (linkCheckRateLimit.getIfPresent(player.uniqueId()) != null) { player.sendMessage(discordSRV.messagesConfig(player).pleaseWaitBeforeRunningThatCommandAgain.asComponent()); return; } linkCheckRateLimit.put(player.uniqueId(), true); player.sendMessage(Component.text("Checking...")); UUID uuid = player.uniqueId(); getBlockReason(uuid, player.username(), false).whenComplete((reason, t) -> { if (t != null) { return; } if (reason == null) { frozen.remove(uuid); } else { frozen.put(uuid, reason); player.sendMessage(reason); } }); } } }
11,109
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitConnectionListener.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitConnectionListener.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.listener; import com.discordsrv.bukkit.BukkitDiscordSRV; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; public class BukkitConnectionListener implements Listener { private final BukkitDiscordSRV discordSRV; public BukkitConnectionListener(BukkitDiscordSRV discordSRV) { this.discordSRV = discordSRV; for (Player onlinePlayer : discordSRV.server().getOnlinePlayers()) { discordSRV.profileManager().loadProfile(onlinePlayer.getUniqueId()); } } @EventHandler(priority = EventPriority.NORMAL) public void onPlayerLoginNormal(PlayerLoginEvent event) { if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) { return; } discordSRV.profileManager().loadProfile(event.getPlayer().getUniqueId()); } @EventHandler(priority = EventPriority.MONITOR) public void onPlayerLoginMonitor(PlayerLoginEvent event) { if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) { // Unload in case got blocked after NORMAL discordSRV.profileManager().unloadProfile(event.getPlayer().getUniqueId()); } } @EventHandler(priority = EventPriority.MONITOR) public void onPlayerQuit(PlayerQuitEvent event) { discordSRV.profileManager().unloadProfile(event.getPlayer().getUniqueId()); } }
2,392
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitDeathListener.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitDeathListener.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.listener; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.event.events.message.receive.game.DeathMessageReceiveEvent; import com.discordsrv.api.player.DiscordSRVPlayer; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.component.PaperComponentHandle; import org.bukkit.event.Cancellable; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; public class BukkitDeathListener implements Listener { private static final PaperComponentHandle<PlayerDeathEvent> COMPONENT_HANDLE; private static final MethodHandle CANCELLED_HANDLE; static { COMPONENT_HANDLE = new PaperComponentHandle<>( PlayerDeathEvent.class, "deathMessage", PlayerDeathEvent::getDeathMessage ); MethodHandle handle = null; try { handle = MethodHandles.lookup().findVirtual( Cancellable.class, "isCancelled", MethodType.methodType(boolean.class) ); } catch (ReflectiveOperationException ignored) {} CANCELLED_HANDLE = handle; } private final BukkitDiscordSRV discordSRV; public BukkitDeathListener(BukkitDiscordSRV discordSRV) { this.discordSRV = discordSRV; } @EventHandler(priority = EventPriority.MONITOR) public void onPlayerDeath(PlayerDeathEvent event) { DiscordSRVPlayer player = discordSRV.playerProvider().player(event.getEntity()); MinecraftComponent component = COMPONENT_HANDLE.getComponent(event); boolean cancelled = false; if (CANCELLED_HANDLE != null) { try { cancelled = (boolean) CANCELLED_HANDLE.invokeExact(event); } catch (Throwable ignored) {} } boolean wasCancelled = cancelled; discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( new DeathMessageReceiveEvent(event, player, component, null, wasCancelled))); } }
3,102
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitChatForwarder.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/listener/chat/BukkitChatForwarder.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.listener.chat; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.event.events.message.receive.game.GameChatMessageReceiveEvent; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.component.PaperComponentHandle; import com.discordsrv.common.channel.GlobalChannel; import com.discordsrv.common.player.IPlayer; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.Listener; public class BukkitChatForwarder implements IBukkitChatForwarder { public static Listener get(BukkitDiscordSRV discordSRV) { // TODO: config option //noinspection ConstantConditions,PointlessBooleanExpression if (1 == 2 && PaperComponentHandle.IS_PAPER_ADVENTURE) { return new PaperChatListener(new BukkitChatForwarder(discordSRV)); } return new BukkitChatListener(new BukkitChatForwarder(discordSRV)); } private final BukkitDiscordSRV discordSRV; protected BukkitChatForwarder(BukkitDiscordSRV discordSRV) { this.discordSRV = discordSRV; } @Override public void publishEvent(Event event, Player player, MinecraftComponent component, boolean cancelled) { IPlayer srvPlayer = discordSRV.playerProvider().player(player); discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( new GameChatMessageReceiveEvent( event, srvPlayer, component, new GlobalChannel(discordSRV), cancelled ) )); } }
2,494
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitChatListener.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/listener/chat/BukkitChatListener.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.listener.chat; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.common.component.util.ComponentUtil; import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; public class BukkitChatListener implements Listener { private final IBukkitChatForwarder forwarder; public BukkitChatListener(IBukkitChatForwarder forwarder) { this.forwarder = forwarder; } @EventHandler(priority = EventPriority.MONITOR) public void onAsyncPlayerChat(org.bukkit.event.player.AsyncPlayerChatEvent event) { MinecraftComponent component = ComponentUtil.toAPI( BukkitComponentSerializer.legacy().deserialize(event.getMessage())); forwarder.publishEvent(event, event.getPlayer(), component, event.isCancelled()); } }
1,770
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitAwardForwarder.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/listener/award/BukkitAwardForwarder.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.listener.award; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.event.events.message.receive.game.AwardMessageReceiveEvent; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.player.IPlayer; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.intellij.lang.annotations.Language; public class BukkitAwardForwarder implements IBukkitAwardForwarder { public static Listener get(BukkitDiscordSRV discordSRV) { BukkitAwardForwarder forwarder = new BukkitAwardForwarder(discordSRV); if (exists("org.bukkit.event.player.PlayerAdvancementDoneEvent")) { // Advancement if (exists("io.papermc.paper.advancement.AdvancementDisplay")) { // Paper (Since 1.17.1) return new PaperModernAdvancementListener(discordSRV, forwarder); } else if (exists("org.bukkit.advancement.AdvancementDisplay")) { // Spigot (Since 1.19) return new SpigotModernAdvancementListener(discordSRV, forwarder); } else { // Generic return new BukkitLegacyAdvancementListener(discordSRV, forwarder); } } else { // Achievement return new BukkitAchievementListener(discordSRV, forwarder); } } private static boolean exists( @Language(value = "JAVA", prefix = "class X{static{Class.forName(\"", suffix = "\")}}") String className ) { try { Class.forName(className); return true; } catch (ClassNotFoundException ignored) { return false; } } private final BukkitDiscordSRV discordSRV; protected BukkitAwardForwarder(BukkitDiscordSRV discordSRV) { this.discordSRV = discordSRV; } public void publishEvent(Object triggeringEvent, Player player, MinecraftComponent advancementName, MinecraftComponent message, boolean cancelled) { IPlayer srvPlayer = discordSRV.playerProvider().player(player); discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( new AwardMessageReceiveEvent( triggeringEvent, srvPlayer, advancementName, message, null, cancelled ) )); } }
3,304
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitAchievementListener.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/listener/award/BukkitAchievementListener.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.listener.award; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.component.util.ComponentUtil; import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerAchievementAwardedEvent; public class BukkitAchievementListener extends AbstractBukkitAwardListener { public BukkitAchievementListener(DiscordSRV discordSRV, IBukkitAwardForwarder forwarder) { super(discordSRV, forwarder); } @EventHandler(priority = EventPriority.MONITOR) public void onPlayerAchievementAwarded(PlayerAchievementAwardedEvent event) { MinecraftComponent name = ComponentUtil.toAPI(BukkitComponentSerializer.legacy().deserialize(event.getAchievement().name())); forwarder.publishEvent(event, event.getPlayer(), name, null, event.isCancelled()); } }
1,828
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitRequiredLinkingConfig.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/config/main/BukkitRequiredLinkingConfig.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.config.main; import com.discordsrv.common.config.main.linking.ServerRequiredLinkingConfig; import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.objectmapping.meta.Comment; public class BukkitRequiredLinkingConfig extends ServerRequiredLinkingConfig { public KickOptions kick = new KickOptions(); @ConfigSerializable public static class KickOptions { @Comment("The event to use for kick.\n" + "Available events: AsyncPlayerPreLoginEvent (preferred), PlayerLoginEvent") public String event = "AsyncPlayerPreLoginEvent"; @Comment("The event priority to use for the kick") public String priority = "NORMAL"; } }
1,594
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitConfig.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/config/main/BukkitConfig.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.config.main; import com.discordsrv.common.config.configurate.annotation.Order; import com.discordsrv.common.config.main.MainConfig; import com.discordsrv.common.config.main.PluginIntegrationConfig; import com.discordsrv.common.config.main.channels.base.BaseChannelConfig; import com.discordsrv.common.config.main.channels.base.server.ServerBaseChannelConfig; import com.discordsrv.common.config.main.channels.base.server.ServerChannelConfig; import org.spongepowered.configurate.objectmapping.ConfigSerializable; @ConfigSerializable public class BukkitConfig extends MainConfig { @Override public BaseChannelConfig createDefaultBaseChannel() { return new ServerBaseChannelConfig(); } @Override public BaseChannelConfig createDefaultChannel() { return new ServerChannelConfig(); } @Order(5) public BukkitRequiredLinkingConfig requiredLinking = new BukkitRequiredLinkingConfig(); @Order(100) public PluginIntegrationConfig integrations = new PluginIntegrationConfig(); @Override public PluginIntegrationConfig integrations() { return integrations; } }
1,993
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitConnectionConfig.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/config/connection/BukkitConnectionConfig.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.config.connection; import com.discordsrv.common.config.connection.ConnectionConfig; import org.spongepowered.configurate.objectmapping.ConfigSerializable; @ConfigSerializable public class BukkitConnectionConfig extends ConnectionConfig { }
1,103
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitMessagesConfigManager.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitMessagesConfigManager.java
package com.discordsrv.bukkit.config.manager; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.config.configurate.manager.MessagesConfigManager; import com.discordsrv.common.config.messages.MessagesConfig; public class BukkitMessagesConfigManager extends MessagesConfigManager<MessagesConfig> { public BukkitMessagesConfigManager(DiscordSRV discordSRV) { super(discordSRV); } @Override public MessagesConfig createConfiguration() { return new MessagesConfig(); } }
526
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitConfigManager.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitConfigManager.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.config.manager; import com.discordsrv.bukkit.config.main.BukkitConfig; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.config.configurate.manager.abstraction.ServerConfigManager; import java.nio.file.Path; public class BukkitConfigManager extends ServerConfigManager<BukkitConfig> { public BukkitConfigManager(DiscordSRV discordSRV) { super(discordSRV); } public BukkitConfigManager(Path dataDirectory) { super(dataDirectory); } @Override public BukkitConfig createConfiguration() { return new BukkitConfig(); } }
1,454
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitConnectionConfigManager.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitConnectionConfigManager.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.config.manager; import com.discordsrv.bukkit.config.connection.BukkitConnectionConfig; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.config.configurate.manager.ConnectionConfigManager; import java.nio.file.Path; public class BukkitConnectionConfigManager extends ConnectionConfigManager<BukkitConnectionConfig> { public BukkitConnectionConfigManager(DiscordSRV discordSRV) { super(discordSRV); } public BukkitConnectionConfigManager(Path dataDirectory) { super(dataDirectory); } @Override public BukkitConnectionConfig createConfiguration() { return new BukkitConnectionConfig(); } }
1,527
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
PlaceholderAPIIntegration.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/integration/PlaceholderAPIIntegration.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.integration; import com.discordsrv.api.event.bus.Subscribe; import com.discordsrv.api.event.events.placeholder.PlaceholderLookupEvent; import com.discordsrv.api.placeholder.PlaceholderLookupResult; import com.discordsrv.api.placeholder.PlainPlaceholderFormat; import com.discordsrv.api.player.DiscordSRVPlayer; import com.discordsrv.api.profile.IProfile; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.module.type.PluginIntegration; import com.discordsrv.common.player.IOfflinePlayer; import me.clip.placeholderapi.PlaceholderAPI; import me.clip.placeholderapi.expansion.PlaceholderExpansion; import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.UUID; public class PlaceholderAPIIntegration extends PluginIntegration<BukkitDiscordSRV> { private static final String OPTIONAL_PREFIX = "placeholderapi_"; private Expansion expansion; public PlaceholderAPIIntegration(BukkitDiscordSRV discordSRV) { super(discordSRV); } @Override public @NotNull String getIntegrationName() { return "PlaceholderAPI"; } @Override public boolean isEnabled() { try { Class.forName("me.clip.placeholderapi.PlaceholderAPI"); } catch (ClassNotFoundException ignored) { return false; } return super.isEnabled(); } @Override public void enable() { expansion = new Expansion(); discordSRV.scheduler().runOnMainThread(() -> expansion.register()); } @Override public void disable() { if (expansion != null) { discordSRV.scheduler().runOnMainThread(() -> expansion.unregister()); } } @Subscribe public void onPlaceholderLookup(PlaceholderLookupEvent event) { String placeholder = event.getPlaceholder(); if (placeholder.startsWith(OPTIONAL_PREFIX)) { placeholder = placeholder.substring(OPTIONAL_PREFIX.length()); } placeholder = "%" + placeholder + "%"; DiscordSRVPlayer srvPlayer = event.getContext(DiscordSRVPlayer.class); Player player = srvPlayer != null ? discordSRV.server().getPlayer(srvPlayer.uniqueId()) : null; if (player != null) { setResult(event, placeholder, PlaceholderAPI.setPlaceholders(player, placeholder)); return; } IProfile profile = event.getContext(IProfile.class); UUID uuid = profile != null ? profile.playerUUID() : null; if (uuid == null) { IOfflinePlayer offlinePlayer = event.getContext(IOfflinePlayer.class); if (offlinePlayer != null) { uuid = offlinePlayer.uniqueId(); } } OfflinePlayer offlinePlayer = uuid != null ? discordSRV.server().getOfflinePlayer(uuid) : null; setResult(event, placeholder, PlaceholderAPI.setPlaceholders(offlinePlayer, placeholder)); } private void setResult(PlaceholderLookupEvent event, String placeholder, String result) { if (result.equals(placeholder)) { // Didn't resolve return; } event.process(PlaceholderLookupResult.success(BukkitComponentSerializer.legacy().deserialize(result))); } public class Expansion extends PlaceholderExpansion { @Override public @NotNull String getIdentifier() { return "discordsrv"; } @Override public @NotNull String getAuthor() { return "DiscordSRV"; } @Override public @NotNull String getVersion() { return discordSRV.versionInfo().version(); } @Override public @NotNull String getName() { return "DiscordSRV"; } @Override public boolean persist() { return true; } @Override public @Nullable String onPlaceholderRequest(Player player, @NotNull String params) { return onRequest(player, params); } @Override public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) { Set<Object> context; if (player != null) { context = new HashSet<>(2); IProfile profile = discordSRV.profileManager().getProfile(player.getUniqueId()); if (profile != null) { context.add(profile); } if (player instanceof Player) { context.add(discordSRV.playerProvider().player((Player) player)); } else { context.add(discordSRV.playerProvider().offlinePlayer(player)); } } else { context = Collections.emptySet(); } String placeholder = "%" + params + "%"; String result = PlainPlaceholderFormat.supplyWith( PlainPlaceholderFormat.Formatting.LEGACY, () -> discordSRV.placeholderService().replacePlaceholders(placeholder, context) ); return placeholder.equals(result) ? null : result; } } }
6,245
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
VaultIntegration.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/integration/VaultIntegration.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.integration; import com.discordsrv.api.module.type.PermissionModule; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.exception.MessageException; import com.discordsrv.common.function.CheckedSupplier; import com.discordsrv.common.future.util.CompletableFutureUtil; import com.discordsrv.common.module.type.PluginIntegration; import net.milkbowl.vault.chat.Chat; import net.milkbowl.vault.permission.Permission; import org.bukkit.OfflinePlayer; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.ServicesManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.UUID; import java.util.concurrent.CompletableFuture; public class VaultIntegration extends PluginIntegration<BukkitDiscordSRV> implements PermissionModule.Basic { private Permission permission; private Chat chat; private boolean permissionAsync; private boolean chatAsync; public VaultIntegration(BukkitDiscordSRV discordSRV) { super(discordSRV); } @Override public @NotNull String getIntegrationName() { return "Vault"; } @Override public int priority(Class<?> type) { // Lower priority than default return -1; } @Override public boolean isEnabled() { try { Class.forName("net.milkbowl.vault.permission.Permission"); } catch (ClassNotFoundException e) { return false; } return super.isEnabled(); } @Override public void enable() { ServicesManager servicesManager = discordSRV.plugin().getServer().getServicesManager(); RegisteredServiceProvider<Permission> permissionRSP = servicesManager.getRegistration(Permission.class); if (permissionRSP != null) { permission = permissionRSP.getProvider(); permissionAsync = isAsync(permission); } RegisteredServiceProvider<Chat> chatRSP = servicesManager.getRegistration(Chat.class); if (chatRSP != null) { chat = chatRSP.getProvider(); chatAsync = isAsync(chat); } } private boolean isAsync(Object vault) { if (vault == null) { return false; } return vault.getClass().getSimpleName().startsWith("LuckPerms"); } @Override public void disable() { permission = null; chat = null; } @Override public boolean supportsOffline() { // Maybe return true; } private <T> CompletableFuture<T> unsupported(@Nullable Object vault) { return CompletableFutureUtil.failed(new MessageException( vault != null ? "Vault backend " + vault.getClass().getName() + " unable to complete request" : "No vault backend available" )); } private <T> CompletableFuture<T> supply(CheckedSupplier<T> supplier, boolean async) { CompletableFuture<T> future = new CompletableFuture<>(); Runnable runnable = () -> { try { future.complete(supplier.get()); } catch (Throwable e) { future.completeExceptionally(e); } }; if (async) { discordSRV.scheduler().run(runnable); } else { discordSRV.scheduler().runOnMainThread(runnable); } return future; } private OfflinePlayer offlinePlayer(UUID player) { return discordSRV.plugin().getServer().getOfflinePlayer(player); } @Override public List<String> getGroups() { String[] groups = permission.getGroups(); return groups != null ? Arrays.asList(groups) : Collections.emptyList(); } @Override public CompletableFuture<Boolean> hasGroup(@NotNull UUID player, @NotNull String groupName, boolean includeInherited) { if (permission == null || !permission.isEnabled() || !permission.hasGroupSupport()) { return unsupported(permission); } return supply(() -> { OfflinePlayer offlinePlayer = offlinePlayer(player); return permission.playerInGroup(null, offlinePlayer, groupName); }, permissionAsync); } @Override public CompletableFuture<Void> addGroup(@NotNull UUID player, @NotNull String groupName) { if (permission == null || !permission.isEnabled() || !permission.hasGroupSupport()) { return unsupported(permission); } return supply(() -> { OfflinePlayer offlinePlayer = offlinePlayer(player); permission.playerAddGroup(null, offlinePlayer, groupName); return null; }, permissionAsync); } @Override public CompletableFuture<Void> removeGroup(@NotNull UUID player, @NotNull String groupName) { if (permission == null || !permission.isEnabled() || !permission.hasGroupSupport()) { return unsupported(permission); } return supply(() -> { OfflinePlayer offlinePlayer = offlinePlayer(player); permission.playerRemoveGroup(null, offlinePlayer, groupName); return null; }, permissionAsync); } @Override public CompletableFuture<Boolean> hasPermission(@NotNull UUID player, @NotNull String permissionNode) { if (permission == null || !permission.isEnabled()) { return unsupported(permission); } return supply(() -> { OfflinePlayer offlinePlayer = offlinePlayer(player); return permission.playerHas(null, offlinePlayer, permissionNode); }, permissionAsync); } @Override public CompletableFuture<String> getPrefix(@NotNull UUID player) { if (chat == null || !chat.isEnabled()) { return unsupported(chat); } return supply(() -> { OfflinePlayer offlinePlayer = offlinePlayer(player); return chat.getPlayerPrefix(null, offlinePlayer); }, chatAsync); } @Override public CompletableFuture<String> getSuffix(@NotNull UUID player) { if (chat == null || !chat.isEnabled()) { return unsupported(chat); } return supply(() -> { OfflinePlayer offlinePlayer = offlinePlayer(player); return chat.getPlayerSuffix(null, offlinePlayer); }, chatAsync); } }
7,349
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
EssentialsXIntegration.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/integration/EssentialsXIntegration.java
package com.discordsrv.bukkit.integration; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.event.bus.Subscribe; import com.discordsrv.api.event.events.channel.GameChannelLookupEvent; import com.discordsrv.api.event.events.message.receive.game.GameChatMessageReceiveEvent; import com.discordsrv.api.module.type.NicknameModule; import com.discordsrv.api.module.type.PunishmentModule; import com.discordsrv.api.player.DiscordSRVPlayer; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.player.BukkitPlayer; import com.discordsrv.common.component.util.ComponentUtil; import com.discordsrv.common.module.type.PluginIntegration; import com.earth2me.essentials.Essentials; import com.earth2me.essentials.User; import com.earth2me.essentials.UserData; import net.essentialsx.api.v2.events.chat.GlobalChatEvent; import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.time.Instant; import java.util.Collection; import java.util.UUID; import java.util.concurrent.CompletableFuture; public class EssentialsXIntegration extends PluginIntegration<BukkitDiscordSRV> implements Listener, PunishmentModule.Mutes, NicknameModule { private final GlobalChannel channel = new GlobalChannel(); public EssentialsXIntegration(BukkitDiscordSRV discordSRV) { super(discordSRV); } @Override public @NotNull String getIntegrationName() { return "Essentials"; } @Override public boolean isEnabled() { try { Class.forName("net.essentialsx.api.v2.events.chat.GlobalChatEvent"); } catch (ClassNotFoundException ignored) { return false; } return super.isEnabled(); } private Essentials get() { return (Essentials) discordSRV.server().getPluginManager().getPlugin("Essentials"); } private CompletableFuture<User> getUser(UUID playerUUID) { return CompletableFuture.supplyAsync(() -> get().getUsers().loadUncachedUser(playerUUID), discordSRV.scheduler().executor()); } @Override public CompletableFuture<String> getNickname(UUID playerUUID) { return getUser(playerUUID).thenApply(UserData::getNickname); } @Override public CompletableFuture<Void> setNickname(UUID playerUUID, String nickname) { return getUser(playerUUID).thenApply(user -> { user.setNickname(nickname); return null; }); } @Override public CompletableFuture<Punishment> getMute(@NotNull UUID playerUUID) { return getUser(playerUUID).thenApply(user -> new Punishment(Instant.ofEpochMilli(user.getMuteTimeout()), user.getMuteReason(), null)); } @Override public CompletableFuture<Void> addMute(@NotNull UUID playerUUID, @Nullable Instant until, @Nullable String reason, @NotNull String punisher) { return getUser(playerUUID).thenApply(user -> { user.setMuted(true); user.setMuteTimeout(until != null ? until.toEpochMilli() : 0); user.setMuteReason(reason); return null; }); } @Override public CompletableFuture<Void> removeMute(@NotNull UUID playerUUID) { return getUser(playerUUID).thenApply(user -> { user.setMuted(false); user.setMuteTimeout(0); user.setMuteReason(null); return null; }); } @EventHandler(priority = org.bukkit.event.EventPriority.MONITOR) public void onGlobalChat(GlobalChatEvent event) { Player player = event.getPlayer(); MinecraftComponent component = ComponentUtil.toAPI( BukkitComponentSerializer.legacy().deserialize(event.getMessage()) ); BukkitPlayer srvPlayer = discordSRV.playerProvider().player(player); boolean cancelled = event.isCancelled(); discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( new GameChatMessageReceiveEvent(event, srvPlayer, component, channel, cancelled) )); } @Subscribe public void onGameChannelLookup(GameChannelLookupEvent event) { if (checkProcessor(event) || !discordSRV.server().getPluginManager().isPluginEnabled("EssentialsChat")) { return; } if (event.isDefault()) { event.process(channel); } } private class GlobalChannel implements GameChannel { @Override public @NotNull String getOwnerName() { return getIntegrationName(); } @Override public @NotNull String getChannelName() { return GameChannel.DEFAULT_NAME; } @Override public boolean isChat() { return true; } @Override public @NotNull Collection<? extends DiscordSRVPlayer> getRecipients() { return discordSRV.playerProvider().allPlayers(); } } }
5,177
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
ChattyChatIntegration.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/ChattyChatIntegration.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.integration.chat; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.event.bus.Subscribe; import com.discordsrv.api.event.events.channel.GameChannelLookupEvent; import com.discordsrv.api.event.events.message.receive.game.GameChatMessageReceiveEvent; import com.discordsrv.api.player.DiscordSRVPlayer; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.player.BukkitPlayer; import com.discordsrv.common.component.util.ComponentUtil; import com.discordsrv.common.logging.NamedLogger; import com.discordsrv.common.module.type.PluginIntegration; import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.jetbrains.annotations.NotNull; import ru.mrbrikster.chatty.api.ChattyApi; import ru.mrbrikster.chatty.api.chats.Chat; import ru.mrbrikster.chatty.api.events.ChattyMessageEvent; import java.util.Collection; import java.util.HashSet; import java.util.Set; public class ChattyChatIntegration extends PluginIntegration<BukkitDiscordSRV> implements Listener { public ChattyChatIntegration(BukkitDiscordSRV discordSRV) { super(discordSRV, new NamedLogger(discordSRV, "CHATTY")); } @Override public @NotNull String getIntegrationName() { return "Chatty"; } @Override public boolean isEnabled() { try { Class.forName("ru.mrbrikster.chatty.api.ChattyApi"); } catch (ClassNotFoundException ignored) { return false; } return super.isEnabled(); } @Override public void enable() { discordSRV.server().getPluginManager().registerEvents(this, discordSRV.plugin()); } @Override public void disable() { HandlerList.unregisterAll(this); } @EventHandler(priority = org.bukkit.event.EventPriority.MONITOR) public void onChattyMessage(ChattyMessageEvent event) { Player player = event.getPlayer(); Chat chat = event.getChat(); MinecraftComponent component = ComponentUtil.toAPI( BukkitComponentSerializer.legacy().deserialize(event.getMessage()) ); BukkitPlayer srvPlayer = discordSRV.playerProvider().player(player); discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( new GameChatMessageReceiveEvent(event, srvPlayer, component, new ChattyChannel(chat), false) )); } @Subscribe public void onGameChannelLookup(GameChannelLookupEvent event) { if (checkProcessor(event)) { return; } ChattyApi api = ChattyApi.get(); if (api == null) { logger().error("ChattyApi == null"); return; } api.getChat(event.getChannelName()) .ifPresent(value -> event.process(new ChattyChannel(value))); } private class ChattyChannel implements GameChannel { private final Chat chat; public ChattyChannel(Chat chat) { this.chat = chat; } @Override public @NotNull String getOwnerName() { return getIntegrationName(); } @Override public @NotNull String getChannelName() { return chat.getName(); } @Override public boolean isChat() { return true; } @Override public @NotNull Set<DiscordSRVPlayer> getRecipients() { Collection<? extends Player> players = chat.getRecipients(null); Set<DiscordSRVPlayer> srvPlayers = new HashSet<>(players.size()); for (Player player : players) { srvPlayers.add(discordSRV.playerProvider().player(player)); } return srvPlayers; } } }
4,787
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
VentureChatIntegration.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/VentureChatIntegration.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.integration.chat; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.event.bus.Subscribe; import com.discordsrv.api.event.events.channel.GameChannelLookupEvent; import com.discordsrv.api.event.events.message.receive.game.GameChatMessageReceiveEvent; import com.discordsrv.api.player.DiscordSRVPlayer; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.player.BukkitPlayer; import com.discordsrv.common.component.util.ComponentUtil; import com.discordsrv.common.logging.NamedLogger; import com.discordsrv.common.module.type.PluginIntegration; import mineverse.Aust1n46.chat.api.MineverseChatAPI; import mineverse.Aust1n46.chat.api.MineverseChatPlayer; import mineverse.Aust1n46.chat.api.events.VentureChatEvent; import mineverse.Aust1n46.chat.channel.ChatChannel; import mineverse.Aust1n46.chat.utilities.Format; import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer; import net.kyori.adventure.text.TextReplacementConfig; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.regex.Pattern; public class VentureChatIntegration extends PluginIntegration<BukkitDiscordSRV> implements Listener { public VentureChatIntegration(BukkitDiscordSRV discordSRV) { super(discordSRV, new NamedLogger(discordSRV, "VENTURECHAT")); } @Override public @NotNull String getIntegrationName() { return "VentureChat"; } @Override public boolean isEnabled() { try { Class.forName("mineverse.Aust1n46.chat.api.events.VentureChatEvent"); } catch (ClassNotFoundException ignored) { return false; } return super.isEnabled(); } @Override public void enable() { discordSRV.server().getPluginManager().registerEvents(this, discordSRV.plugin()); } @Override public void disable() { HandlerList.unregisterAll(this); } @EventHandler(priority = org.bukkit.event.EventPriority.MONITOR) public void onAsyncChatHook(VentureChatEvent event) { MineverseChatPlayer chatPlayer = event.getMineverseChatPlayer(); Player player = chatPlayer.getPlayer(); if (player == null) { logger().debug("Bukkit player == null for " + chatPlayer.getName()); return; } ChatChannel channel = event.getChannel(); MinecraftComponent component = ComponentUtil.toAPI( BukkitComponentSerializer.legacy().deserialize(event.getChat()) ); BukkitPlayer srvPlayer = discordSRV.playerProvider().player(player); discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( new GameChatMessageReceiveEvent(event, srvPlayer, component, new VentureChatChannel(channel), false) )); } @Subscribe public void onGameChannelLookup(GameChannelLookupEvent event) { if (checkProcessor(event)) { return; } ChatChannel channel; if (event.isDefault()) { channel = ChatChannel.getDefaultChannel(); } else { channel = ChatChannel.getChannel(event.getChannelName()); } if (channel != null) { event.process(new VentureChatChannel(channel)); } } private class VentureChatChannel implements GameChannel { private final ChatChannel channel; public VentureChatChannel(ChatChannel channel) { this.channel = channel; } @Override public @NotNull String getOwnerName() { return getIntegrationName(); } @Override public @NotNull String getChannelName() { return channel.getName(); } @Override public boolean isChat() { return true; } @Override public @NotNull Set<DiscordSRVPlayer> getRecipients() { Collection<MineverseChatPlayer> chatPlayers = MineverseChatAPI.getMineverseChatPlayers(); Set<DiscordSRVPlayer> players = new HashSet<>(chatPlayers.size()); for (MineverseChatPlayer chatPlayer : chatPlayers) { if (!chatPlayer.isListening(channel.getName())) { continue; } Player bukkitPlayer = chatPlayer.getPlayer(); if (bukkitPlayer == null) { continue; } if (channel.hasPermission() && !bukkitPlayer.hasPermission(channel.getPermission())) { continue; } players.add(discordSRV.playerProvider().player(bukkitPlayer)); } return players; } @Override public void sendMessageToPlayer(@NotNull DiscordSRVPlayer player, @NotNull MinecraftComponent component) { MineverseChatPlayer chatPlayer = MineverseChatAPI.getMineverseChatPlayer(player.uniqueId()); if (chatPlayer.hasFilter() && channel.isFiltered()) { component = ComponentUtil.toAPI( ComponentUtil.fromAPI(component) .replaceText( TextReplacementConfig.builder() .match(Pattern.compile("[\\w\\W]+")) .replacement(match -> match.content(Format.FilterChat(match.content()))) .build() ) ); } player.sendMessage(component); } } }
6,733
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
TownyChatIntegration.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/TownyChatIntegration.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.integration.chat; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.event.bus.Subscribe; import com.discordsrv.api.event.events.channel.GameChannelLookupEvent; import com.discordsrv.api.event.events.message.receive.game.GameChatMessageReceiveEvent; import com.discordsrv.api.player.DiscordSRVPlayer; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.player.BukkitPlayer; import com.discordsrv.common.component.util.ComponentUtil; import com.discordsrv.common.logging.NamedLogger; import com.discordsrv.common.module.type.PluginIntegration; import com.palmergames.bukkit.TownyChat.Chat; import com.palmergames.bukkit.TownyChat.channels.Channel; import com.palmergames.bukkit.TownyChat.events.AsyncChatHookEvent; import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.HashSet; import java.util.Set; public class TownyChatIntegration extends PluginIntegration<BukkitDiscordSRV> implements Listener { public TownyChatIntegration(BukkitDiscordSRV discordSRV) { super(discordSRV, new NamedLogger(discordSRV, "TOWNYCHAT")); } @Override public @NotNull String getIntegrationName() { return "TownyChat"; } @Override public boolean isEnabled() { try { Class.forName("com.palmergames.bukkit.TownyChat.Chat"); } catch (ClassNotFoundException ignored) { return false; } return super.isEnabled(); } @Override public void enable() { discordSRV.server().getPluginManager().registerEvents(this, discordSRV.plugin()); } @Override public void disable() { HandlerList.unregisterAll(this); } @EventHandler(priority = org.bukkit.event.EventPriority.MONITOR) public void onAsyncChatHook(AsyncChatHookEvent event) { Player player = event.getPlayer(); Channel channel = event.getChannel(); MinecraftComponent component = ComponentUtil.toAPI( BukkitComponentSerializer.legacy().deserialize(event.getMessage()) ); BukkitPlayer srvPlayer = discordSRV.playerProvider().player(player); boolean cancelled = event.isCancelled(); discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( new GameChatMessageReceiveEvent(event, srvPlayer, component, new TownyChatChannel(channel), cancelled) )); } @Subscribe public void onGameChannelLookup(GameChannelLookupEvent event) { if (checkProcessor(event)) { return; } Chat chat = (Chat) Bukkit.getPluginManager().getPlugin("TownyChat"); if (chat == null) { logger().debug("TownyChat main class == null"); return; } Channel channel; if (event.isDefault()) { channel = chat.getChannelsHandler().getDefaultChannel(); } else { channel = chat.getChannelsHandler().getChannel(event.getChannelName()); } if (channel != null) { event.process(new TownyChatChannel(channel)); } } private class TownyChatChannel implements GameChannel { private final Channel channel; public TownyChatChannel(Channel channel) { this.channel = channel; } @Override public @NotNull String getOwnerName() { return getIntegrationName(); } @Override public @NotNull String getChannelName() { return channel.getName(); } @Override public boolean isChat() { return true; } @Override public @NotNull Set<DiscordSRVPlayer> getRecipients() { Collection<BukkitPlayer> players = discordSRV.playerProvider().allPlayers(); Set<DiscordSRVPlayer> filteredPlayers = new HashSet<>(players.size()); for (BukkitPlayer player : players) { if (!channel.isPresent(player.username())) { continue; } String permission = channel.getPermission(); if (permission != null && !player.hasPermission(permission)) { continue; } filteredPlayers.add(player); } return filteredPlayers; } } }
5,501
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
McMMOChatIntegration.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/McMMOChatIntegration.java
package com.discordsrv.bukkit.integration.chat; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.event.bus.EventPriority; import com.discordsrv.api.event.bus.Subscribe; import com.discordsrv.api.event.events.channel.GameChannelLookupEvent; import com.discordsrv.api.event.events.message.receive.game.GameChatMessageReceiveEvent; import com.discordsrv.api.player.DiscordSRVPlayer; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.player.BukkitPlayer; import com.discordsrv.common.component.util.ComponentUtil; import com.discordsrv.common.logging.NamedLogger; import com.discordsrv.common.module.type.PluginIntegration; import com.gmail.nossr50.api.ChatAPI; import com.gmail.nossr50.chat.author.Author; import com.gmail.nossr50.chat.author.PlayerAuthor; import com.gmail.nossr50.events.chat.McMMOAdminChatEvent; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcmmo.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.Set; public class McMMOChatIntegration extends PluginIntegration<BukkitDiscordSRV> implements Listener { private final McMMOAdminChannel adminChannel = new McMMOAdminChannel(); public McMMOChatIntegration(BukkitDiscordSRV discordSRV) { super(discordSRV, new NamedLogger(discordSRV, "MCMMO")); } @Override public @NotNull String getIntegrationName() { return "mcMMO"; } @Override public boolean isEnabled() { try { Class.forName("com.gmail.nossr50.mcMMO"); } catch (ClassNotFoundException ignored) { return false; } return super.isEnabled(); } @Override public void enable() { discordSRV.server().getPluginManager().registerEvents(this, discordSRV.plugin()); } @Override public void disable() { HandlerList.unregisterAll(this); } @Subscribe(priority = EventPriority.EARLY) public void onGameChatMessageReceive(GameChatMessageReceiveEvent event) { Player player = discordSRV.server().getPlayer(event.getPlayer().uniqueId()); if (!player.hasMetadata("mcMMO: Player Data")) { return; } if (ChatAPI.isUsingPartyChat(player)) { logger().debug(player.getName() + " is using party chat"); event.setCancelled(true); } else if (ChatAPI.isUsingAdminChat(player)) { logger().debug(player.getName() + " is using admin chat"); event.setCancelled(true); } } @EventHandler(priority = org.bukkit.event.EventPriority.MONITOR) public void onMcMMOAdminChat(McMMOAdminChatEvent event) { Author author = event.getAuthor(); if (!author.isPlayer()) return; Player player = ((PlayerAuthor) author).getPlayer(); String json = GsonComponentSerializer.gson().serialize(event.getChatMessage().getChatMessage()); MinecraftComponent component = ComponentUtil.toAPI( BukkitComponentSerializer.gson().deserialize(json) ); BukkitPlayer srvPlayer = discordSRV.playerProvider().player(player); boolean cancelled = event.isCancelled(); discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( new GameChatMessageReceiveEvent(event, srvPlayer, component, adminChannel, cancelled) )); } @Subscribe public void onGameChannelLookup(GameChannelLookupEvent event) { if (checkProcessor(event)) { return; } if (event.getChannelName().equalsIgnoreCase(adminChannel.getChannelName())) { event.process(adminChannel); } } private class McMMOAdminChannel implements GameChannel { @Override public @NotNull String getOwnerName() { return getIntegrationName(); } @Override public @NotNull String getChannelName() { return "admin"; } @Override public boolean isChat() { return true; } @Override public @NotNull Set<DiscordSRVPlayer> getRecipients() { return Collections.emptySet(); } @Override public void sendMessage(@NotNull MinecraftComponent component) { mcMMO mcMMO = (mcMMO) discordSRV.server().getPluginManager().getPlugin("mcMMO"); if (mcMMO == null) return; String message = BukkitComponentSerializer.legacy().serialize(ComponentUtil.fromAPI(component)); mcMMO.getChatManager().processConsoleMessage(message); } } }
4,932
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
LunaChatIntegration.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/LunaChatIntegration.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.integration.chat; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.event.bus.Subscribe; import com.discordsrv.api.event.events.channel.GameChannelLookupEvent; import com.discordsrv.api.event.events.message.receive.game.GameChatMessageReceiveEvent; import com.discordsrv.api.player.DiscordSRVPlayer; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.player.BukkitPlayer; import com.discordsrv.common.component.util.ComponentUtil; import com.discordsrv.common.logging.NamedLogger; import com.discordsrv.common.module.type.PluginIntegration; import com.github.ucchyocean.lc3.LunaChatAPI; import com.github.ucchyocean.lc3.LunaChatBukkit; import com.github.ucchyocean.lc3.bukkit.event.LunaChatBukkitChannelChatEvent; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.member.ChannelMember; import com.github.ucchyocean.lc3.member.ChannelMemberPlayer; import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer; import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer; import net.md_5.bungee.api.chat.BaseComponent; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.List; import java.util.Set; public class LunaChatIntegration extends PluginIntegration<BukkitDiscordSRV> implements Listener { public LunaChatIntegration(BukkitDiscordSRV discordSRV) { super(discordSRV, new NamedLogger(discordSRV, "LUNACHAT")); } @Override public @NotNull String getIntegrationName() { return "LunaChat"; } @Override public boolean isEnabled() { try { Class.forName("com.github.ucchyocean.lc3.LunaChatAPI"); } catch (ClassNotFoundException ignored) { return false; } return super.isEnabled(); } @Override public void enable() { discordSRV.server().getPluginManager().registerEvents(this, discordSRV.plugin()); } @Override public void disable() { HandlerList.unregisterAll(this); } @EventHandler(priority = org.bukkit.event.EventPriority.MONITOR) public void onLunaChatBukkitChannelChat(LunaChatBukkitChannelChatEvent event) { ChannelMember member = event.getMember(); if (!(member instanceof ChannelMemberPlayer)) { return; } Player player = ((ChannelMemberPlayer) member).getPlayer(); Channel channel = event.getChannel(); MinecraftComponent component = ComponentUtil.toAPI( BukkitComponentSerializer.legacy().deserialize(event.getNgMaskedMessage()) ); BukkitPlayer srvPlayer = discordSRV.playerProvider().player(player); boolean cancelled = event.isCancelled(); discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( new GameChatMessageReceiveEvent(event, srvPlayer, component, new LunaChatChannel(channel), cancelled) )); } @Subscribe public void onGameChannelLookup(GameChannelLookupEvent event) { if (checkProcessor(event)) { return; } LunaChatBukkit lunaChat = LunaChatBukkit.getInstance(); if (lunaChat == null) { logger().debug("LunaChatBukkit == null"); return; } LunaChatAPI api = lunaChat.getLunaChatAPI(); if (api == null) { logger().debug("LunaChatAPI == null"); return; } Channel channel = api.getChannel(event.getChannelName()); if (channel != null) { event.process(new LunaChatChannel(channel)); } } private class LunaChatChannel implements GameChannel { private final Channel channel; public LunaChatChannel(Channel channel) { this.channel = channel; } @Override public @NotNull String getOwnerName() { return getIntegrationName(); } @Override public @NotNull String getChannelName() { return channel.getName(); } @Override public boolean isChat() { return true; } @Override public @NotNull Set<DiscordSRVPlayer> getRecipients() { List<ChannelMember> members = channel.getMembers(); Set<DiscordSRVPlayer> players = new HashSet<>(members.size()); for (ChannelMember member : members) { if (!(member instanceof ChannelMemberPlayer)) { continue; } Player player = ((ChannelMemberPlayer) member).getPlayer(); players.add(discordSRV.playerProvider().player(player)); } return players; } @Override public void sendMessage(@NotNull MinecraftComponent component) { BaseComponent[] baseComponent = BungeeComponentSerializer.get().serialize(ComponentUtil.fromAPI(component)); for (ChannelMember member : channel.getMembers()) { if (member instanceof ChannelMemberPlayer) { continue; } member.sendMessage(baseComponent); } } } }
6,265
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
GriefPreventionChatIntegration.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/GriefPreventionChatIntegration.java
package com.discordsrv.bukkit.integration.chat; import com.discordsrv.api.event.bus.EventPriority; import com.discordsrv.api.event.bus.Subscribe; import com.discordsrv.api.event.events.message.receive.game.GameChatMessageReceiveEvent; import com.discordsrv.api.player.DiscordSRVPlayer; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.logging.NamedLogger; import com.discordsrv.common.module.type.PluginIntegration; import me.ryanhamshire.GriefPrevention.GriefPrevention; import org.jetbrains.annotations.NotNull; public class GriefPreventionChatIntegration extends PluginIntegration<BukkitDiscordSRV> { public GriefPreventionChatIntegration(BukkitDiscordSRV discordSRV) { super(discordSRV, new NamedLogger(discordSRV, "GRIEFPREVENTION")); } @Override public @NotNull String getIntegrationName() { return "GriefPrevention"; } @Override public boolean isEnabled() { try { Class.forName("me.ryanhamshire.GriefPrevention.GriefPrevention"); } catch (ClassNotFoundException ignored) { return false; } return super.isEnabled(); } @Subscribe(priority = EventPriority.EARLY) public void onGameChatMessageReceive(GameChatMessageReceiveEvent event) { GriefPrevention griefPrevention = (GriefPrevention) discordSRV.server().getPluginManager().getPlugin(getIntegrationName()); if (griefPrevention == null) { return; } DiscordSRVPlayer player = event.getPlayer(); if (griefPrevention.dataStore.isSoftMuted(player.uniqueId())) { logger().debug(player.username() + " is softmuted"); event.setCancelled(true); } } }
1,735
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitGameCommandExecutionHelper.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/command/game/BukkitGameCommandExecutionHelper.java
package com.discordsrv.bukkit.command.game; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.command.PaperCommandMap; import com.discordsrv.common.command.game.GameCommandExecutionHelper; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.concurrent.CompletableFuture; public class BukkitGameCommandExecutionHelper implements GameCommandExecutionHelper { private final BukkitDiscordSRV discordSRV; public BukkitGameCommandExecutionHelper(BukkitDiscordSRV discordSRV) { this.discordSRV = discordSRV; } @Override public CompletableFuture<List<String>> suggestCommands(List<String> parts) { String commandName = !parts.isEmpty() ? parts.remove(0) : null; Command command = commandName != null ? discordSRV.server().getPluginCommand(commandName) : null; if (command == null) { if (parts.size() > 1) { // Command is not known but there are arguments, nothing to auto complete... return CompletableFuture.completedFuture(Collections.emptyList()); } else { // List out commands List<String> suggestions = new ArrayList<>(); if (PaperCommandMap.IS_AVAILABLE) { // If Paper's CommandMap is available we can list out 'root' commands CompletableFuture<List<String>> future = new CompletableFuture<>(); discordSRV.scheduler().runOnMainThread(discordSRV.server().getConsoleSender(), () -> { try { for (String cmd : PaperCommandMap.getKnownCommands(discordSRV.server())) { if (commandName == null || cmd.startsWith(commandName)) { suggestions.add(cmd); } } future.complete(suggestions); } catch (Throwable t) { future.completeExceptionally(t); } }); return future; } return CompletableFuture.completedFuture(suggestions); } } // Get the arguments minus the last one (if any) String prefix = parts.isEmpty() ? "" : String.join(" ", parts.subList(0, parts.size() - 1)) + " "; CompletableFuture<List<String>> future = new CompletableFuture<>(); CommandSender commandSender = discordSRV.server().getConsoleSender(); discordSRV.scheduler().runOnMainThread(commandSender, () -> { try { List<String> completions = command.tabComplete(commandSender, commandName, parts.toArray(new String[0])); List<String> suggestions = new ArrayList<>(); for (String suggestion : completions) { suggestions.add(commandName + " " + prefix + suggestion); } future.complete(suggestions); } catch (Throwable t) { future.completeExceptionally(t); } }); return future; } @Override public List<String> getAliases(String command) { PluginCommand pluginCommand = discordSRV.server().getPluginCommand(command); if (pluginCommand == null) { return Collections.emptyList(); } List<String> aliases = new ArrayList<>(pluginCommand.getAliases()); aliases.add(pluginCommand.getName()); String pluginName = pluginCommand.getName().toLowerCase(Locale.ROOT); int originalMax = aliases.size(); for (int i = 0; i < originalMax; i++) { // plugin:command aliases.add(pluginName + ":" + aliases.get(i)); } return aliases; } @Override public boolean isSameCommand(String command1, String command2) { PluginCommand pluginCommand1 = discordSRV.server().getPluginCommand(command1); PluginCommand pluginCommand2 = discordSRV.server().getPluginCommand(command2); return pluginCommand1 == pluginCommand2; } }
4,342
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitBasicCommandHandler.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/BukkitBasicCommandHandler.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.command.game.handler; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.command.game.abstraction.GameCommand; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; import org.bukkit.command.TabCompleter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.List; public class BukkitBasicCommandHandler extends AbstractBukkitCommandExecutor implements TabCompleter { public BukkitBasicCommandHandler(BukkitDiscordSRV discordSRV) { super(discordSRV); } @Override public @Nullable List<String> onTabComplete( @NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args ) { return handler.suggest(sender(sender), alias, Arrays.asList(args)); } @Override public void registerCommand(GameCommand command) { discordSRV.scheduler().runOnMainThread(() -> { PluginCommand pluginCommand = command(command); if (pluginCommand == null) { logger.error("Failed to create command " + command.getLabel()); return; } logger.debug("Registering command " + command.getLabel() + " with basic handler"); handler.registerCommand(command); pluginCommand.setExecutor(this); pluginCommand.setTabCompleter(this); }); } }
2,400
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AbstractBukkitCommandHandler.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/AbstractBukkitCommandHandler.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.command.game.handler; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.command.game.sender.BukkitCommandSender; import com.discordsrv.common.command.game.abstraction.GameCommand; import com.discordsrv.common.command.game.handler.ICommandHandler; import com.discordsrv.common.command.game.sender.ICommandSender; import com.discordsrv.common.logging.Logger; import com.discordsrv.common.logging.NamedLogger; import org.bukkit.Server; import org.bukkit.command.CommandMap; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.PluginCommand; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.lang.reflect.Constructor; import java.util.Locale; public abstract class AbstractBukkitCommandHandler implements ICommandHandler { private static final MethodHandle COMMAND_MAP_HANDLE; static { MethodHandle handle = null; try { handle = MethodHandles.lookup().findVirtual( Server.class, "getCommandMap", MethodType.methodType(CommandMap.class) ); } catch (ReflectiveOperationException ignored) {} COMMAND_MAP_HANDLE = handle; } public static AbstractBukkitCommandHandler get(BukkitDiscordSRV discordSRV) { try { Class.forName("me.lucko.commodore.Commodore"); return new CommodoreHandler(discordSRV); } catch (Throwable e) { BukkitBasicCommandHandler handler = new BukkitBasicCommandHandler(discordSRV); if (e instanceof ClassNotFoundException) { handler.logger.debug("Brigadier classes not present, not using commodore"); } else { handler.logger.debug("Failed to initialize Commodore", e); } return handler; } } protected final BukkitDiscordSRV discordSRV; protected final Logger logger; public AbstractBukkitCommandHandler(BukkitDiscordSRV discordSRV) { this.discordSRV = discordSRV; this.logger = new NamedLogger(discordSRV, "COMMAND_HANDLER"); } protected ICommandSender sender(CommandSender commandSender) { if (commandSender instanceof Player) { return discordSRV.playerProvider().player((Player) commandSender); } else if (commandSender instanceof ConsoleCommandSender) { return discordSRV.console(); } else { return new BukkitCommandSender(discordSRV, commandSender, () -> discordSRV.audiences().sender(commandSender)); } } protected PluginCommand command(GameCommand gameCommand) { String label = gameCommand.getLabel(); PluginCommand pluginCommand = discordSRV.plugin().getCommand(label); if (pluginCommand != null) { logger.debug("PluginCommand available for \"" + label + "\""); return pluginCommand; } if (COMMAND_MAP_HANDLE == null) { logger.debug("Unable to get command from command map"); return null; } PluginCommand command = null; try { Constructor<?> constructor = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class); constructor.setAccessible(true); command = (PluginCommand) constructor.newInstance(label, discordSRV.plugin()); CommandMap commandMap = (CommandMap) COMMAND_MAP_HANDLE.invokeExact(discordSRV.server()); boolean result = commandMap.register(label, discordSRV.plugin().getName().toLowerCase(Locale.ROOT), command); if (result) { logger.debug("Registered command \"" + label + "\" in CommandMap successfully"); } else { logger.debug("Registered command \"" + label + "\" into CommandMap but with fallback prefix"); } } catch (Throwable t) { logger.debug("Failed to register command \"" + label + "\" to CommandMap", t); } return command; } }
5,055
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
CommodoreHandler.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/CommodoreHandler.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.command.game.handler; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.command.game.abstraction.GameCommand; import com.discordsrv.common.command.game.handler.util.BrigadierUtil; import com.mojang.brigadier.tree.LiteralCommandNode; import me.lucko.commodore.Commodore; import me.lucko.commodore.CommodoreProvider; import org.bukkit.command.PluginCommand; /** * No avoiding basic handler on Bukkit. Commodore only sends the command tree to the client, nothing else. */ public class CommodoreHandler extends BukkitBasicCommandHandler { private final Commodore commodore; public CommodoreHandler(BukkitDiscordSRV discordSRV) { super(discordSRV); this.commodore = CommodoreProvider.getCommodore(discordSRV.plugin()); } @Override public void registerCommand(GameCommand command) { logger.debug("Registering command " + command.getLabel() + " with commodore"); PluginCommand pluginCommand = command(command); if (pluginCommand == null) { logger.error("Failed to create command " + command.getLabel()); return; } handler.registerCommand(command); pluginCommand.setExecutor(this); pluginCommand.setTabCompleter(this); discordSRV.scheduler().runOnMainThread(() -> { LiteralCommandNode<?> commandNode = BrigadierUtil.convertToBrigadier(command, null); commodore.register(pluginCommand, commandNode); }); } }
2,355
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AbstractBukkitCommandExecutor.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/AbstractBukkitCommandExecutor.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.command.game.handler; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.command.game.handler.BasicCommandHandler; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; import java.util.Arrays; public abstract class AbstractBukkitCommandExecutor extends AbstractBukkitCommandHandler implements CommandExecutor { protected final BasicCommandHandler handler = new BasicCommandHandler(); public AbstractBukkitCommandExecutor(BukkitDiscordSRV discordSRV) { super(discordSRV); } @Override public boolean onCommand( @NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args ) { handler.execute(sender(sender), label, Arrays.asList(args)); return true; } }
1,794
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitCommandSender.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/command/game/sender/BukkitCommandSender.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.command.game.sender; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.command.game.sender.ICommandSender; import net.kyori.adventure.audience.Audience; import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; import java.util.function.Supplier; public class BukkitCommandSender implements ICommandSender { protected final BukkitDiscordSRV discordSRV; protected final CommandSender commandSender; protected final Supplier<Audience> audienceSupplier; public BukkitCommandSender(BukkitDiscordSRV discordSRV, CommandSender commandSender, Supplier<Audience> audienceSupplier) { this.discordSRV = discordSRV; this.commandSender = commandSender; this.audienceSupplier = audienceSupplier; } @Override public boolean hasPermission(String permission) { return commandSender.hasPermission(permission); } @Override public void runCommand(String command) { discordSRV.scheduler().runOnMainThread(commandSender, () -> discordSRV.server().dispatchCommand(commandSender, command)); } @Override public @NotNull Audience audience() { return audienceSupplier.get(); } }
2,076
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitPluginManager.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/plugin/BukkitPluginManager.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.plugin; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.plugin.Plugin; import com.discordsrv.common.plugin.PluginManager; import org.bukkit.plugin.PluginDescriptionFile; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class BukkitPluginManager implements PluginManager { private final BukkitDiscordSRV discordSRV; public BukkitPluginManager(BukkitDiscordSRV discordSRV) { this.discordSRV = discordSRV; } @Override public boolean isPluginEnabled(String pluginName) { return discordSRV.server().getPluginManager().isPluginEnabled(pluginName); } @Override public List<Plugin> getPlugins() { return Arrays.stream(discordSRV.server().getPluginManager().getPlugins()) .map(plugin -> { PluginDescriptionFile description = plugin.getDescription(); return new Plugin(plugin.getName(), description.getVersion(), description.getAuthors()); }) .collect(Collectors.toList()); } }
1,953
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitConsole.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/console/BukkitConsole.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.console; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.command.game.sender.BukkitCommandSender; import com.discordsrv.bukkit.console.executor.BukkitCommandExecutorProvider; import com.discordsrv.common.command.game.executor.CommandExecutorProvider; import com.discordsrv.common.console.Console; import com.discordsrv.common.logging.NamedLogger; import com.discordsrv.common.logging.backend.LoggingBackend; import com.discordsrv.common.logging.backend.impl.JavaLoggerImpl; import com.discordsrv.common.logging.backend.impl.Log4JLoggerImpl; public class BukkitConsole extends BukkitCommandSender implements Console { private final LoggingBackend loggingBackend; private final CommandExecutorProvider executorProvider; public BukkitConsole(BukkitDiscordSRV discordSRV) { super(discordSRV, discordSRV.server().getConsoleSender(), () -> discordSRV.audiences().console()); LoggingBackend logging; try { // Check that log4j is there Class.forName("org.apache.logging.log4j.core.Filter"); logging = Log4JLoggerImpl.getRoot(); } catch (ClassNotFoundException ignored) { // Log4j with Filter has been in the vanilla server since Minecraft 1.7, // this is mostly for Bukkit servers that don't use the vanilla server software new NamedLogger(discordSRV, "CONSOLE").debug("Not using Log4j for advanced console features"); logging = JavaLoggerImpl.getRoot(); } this.loggingBackend = logging; this.executorProvider = new BukkitCommandExecutorProvider(discordSRV); } @Override public LoggingBackend loggingBackend() { return loggingBackend; } @Override public CommandExecutorProvider commandExecutorProvider() { return executorProvider; } }
2,718
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitCommandExecutorProvider.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/console/executor/BukkitCommandExecutorProvider.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.console.executor; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.command.game.executor.CommandExecutor; import com.discordsrv.common.command.game.executor.CommandExecutorProvider; import com.discordsrv.common.component.util.ComponentUtil; import net.kyori.adventure.text.Component; import org.bukkit.Server; import org.bukkit.command.CommandSender; import java.util.function.Consumer; public class BukkitCommandExecutorProvider implements CommandExecutorProvider { private static final boolean HAS_PAPER_FORWARDING; static { boolean has = false; try { //noinspection JavaReflectionMemberAccess Server.class.getDeclaredMethod("createCommandSender", Consumer.class); has = true; } catch (Throwable ignored) {} HAS_PAPER_FORWARDING = has; } private final BukkitDiscordSRV discordSRV; public BukkitCommandExecutorProvider(BukkitDiscordSRV discordSRV) { this.discordSRV = discordSRV; } @Override public CommandExecutor getConsoleExecutor(Consumer<Component> componentConsumer) { if (HAS_PAPER_FORWARDING) { try { CommandSender sender = new PaperCommandFeedbackExecutor( discordSRV.server(), apiComponent -> componentConsumer.accept(ComponentUtil.fromAPI(apiComponent)) ).sender(); return new CommandSenderExecutor(discordSRV, sender); } catch (Throwable ignored) {} } CommandSender commandSender = new BukkitCommandFeedbackExecutorProxy(discordSRV.server().getConsoleSender(), componentConsumer).getProxy(); return new CommandSenderExecutor(discordSRV, commandSender); } }
2,630
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
CommandSenderExecutor.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/console/executor/CommandSenderExecutor.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.console.executor; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.command.game.executor.CommandExecutor; import org.bukkit.command.CommandSender; public class CommandSenderExecutor implements CommandExecutor { private final BukkitDiscordSRV discordSRV; private final CommandSender commandSender; public CommandSenderExecutor(BukkitDiscordSRV discordSRV, CommandSender commandSender) { this.discordSRV = discordSRV; this.commandSender = commandSender; } @Override public void runCommand(String command) { discordSRV.scheduler().runOnMainThread(commandSender, () -> discordSRV.server().dispatchCommand(commandSender, command)); } }
1,575
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitScheduler.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/BukkitScheduler.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.scheduler; import com.discordsrv.bukkit.BukkitDiscordSRV; public class BukkitScheduler extends AbstractBukkitScheduler { public BukkitScheduler(BukkitDiscordSRV discordSRV) { super(discordSRV); } @Override public void runOnMainThread(Runnable task) { checkDisable(task, (server, plugin) -> server.getScheduler().runTask(plugin, task)); } @Override public void runOnMainThreadLaterInTicks(Runnable task, int ticks) { checkDisable(task, (server, plugin) -> server.getScheduler().runTaskLater(plugin, task, ticks)); } @Override public void runOnMainThreadAtFixedRateInTicks(Runnable task, int initialTicks, int rateTicks) { checkDisable(task, (server, plugin) -> server.getScheduler().runTaskTimer(plugin, task, initialTicks, rateTicks)); } }
1,682
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
FoliaScheduler.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/FoliaScheduler.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.scheduler; import com.discordsrv.bukkit.BukkitDiscordSRV; public class FoliaScheduler extends AbstractBukkitScheduler implements IFoliaScheduler { public FoliaScheduler(BukkitDiscordSRV discordSRV) { super(discordSRV); } @Override public void runOnMainThread(Runnable task) { checkDisable(task, (server, plugin) -> IFoliaScheduler.super.runOnMainThread(task)); } @Override public void runOnMainThreadLaterInTicks(Runnable task, int ticks) { checkDisable(task, (server, plugin) -> IFoliaScheduler.super.runOnMainThreadLaterInTicks(task, ticks)); } @Override public void runOnMainThreadAtFixedRateInTicks(Runnable task, int initialTicks, int rateTicks) { checkDisable(task, (server, plugin) -> IFoliaScheduler.super.runOnMainThreadAtFixedRateInTicks(task, initialTicks, rateTicks)); } }
1,727
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
AbstractBukkitScheduler.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/AbstractBukkitScheduler.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.scheduler; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.DiscordSRVBukkitBootstrap; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.scheduler.ServerScheduler; import com.discordsrv.common.scheduler.StandardScheduler; import org.bukkit.Server; import org.bukkit.plugin.Plugin; import java.util.function.BiConsumer; public abstract class AbstractBukkitScheduler extends StandardScheduler implements ServerScheduler, IBukkitScheduler { protected final BukkitDiscordSRV discordSRV; public AbstractBukkitScheduler(BukkitDiscordSRV discordSRV) { super(discordSRV); this.discordSRV = discordSRV; } protected void checkDisable(Runnable task, BiConsumer<Server, Plugin> runNormal) { // Can't run tasks when disabling, so we'll push those to the bootstrap to run after disable if (!discordSRV.plugin().isEnabled() && discordSRV.status() == DiscordSRV.Status.SHUTTING_DOWN) { ((DiscordSRVBukkitBootstrap) discordSRV.bootstrap()).mainThreadTasksForDisable().add(task); return; } runWithArgs(runNormal); } @Override public void runWithArgs(BiConsumer<Server, Plugin> runNormal) { runNormal.accept(discordSRV.server(), discordSRV.plugin()); } }
2,163
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitTranslationLoader.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/component/translation/BukkitTranslationLoader.java
package com.discordsrv.bukkit.component.translation; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.component.translation.Translation; import com.discordsrv.common.component.translation.TranslationRegistry; import com.discordsrv.common.logging.NamedLogger; import com.fasterxml.jackson.databind.JsonNode; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.Properties; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Stream; public class BukkitTranslationLoader { private final BukkitDiscordSRV discordSRV; private final NamedLogger logger; public BukkitTranslationLoader(BukkitDiscordSRV discordSRV) { this.discordSRV = discordSRV; this.logger = new NamedLogger(discordSRV, "TRANSLATION_LOADER"); } public void reload() { try { TranslationRegistry registry = discordSRV.componentFactory().translationRegistry(); registry.clear(); AtomicBoolean any = new AtomicBoolean(false); Path languages = discordSRV.dataDirectory().resolve("game_languages"); if (Files.exists(languages)) { loadFromFiles(languages, registry, any); } loadMCTranslations(any); if (!any.get()) { logger.warning("No Minecraft translations were found, some components may not render correctly"); } } catch (Throwable t) { logger.error("Failed to reload languages", t); } } private void loadFromFiles(Path folder, TranslationRegistry registry, AtomicBoolean any) throws IOException { try (Stream<Path> paths = Files.list(folder)) { paths.forEach(path -> { String fileName = path.getFileName().toString(); int lastDot = fileName.lastIndexOf("\\."); String extension = lastDot == -1 ? null : fileName.substring(lastDot + 1); if (extension == null || !(extension.equals("json") || extension.equals("lang"))) { discordSRV.logger().warning("Unexpected file in game_languages: " + fileName); return; } try { String language = fileName.substring(0, lastDot); Locale locale = Locale.forLanguageTag(language); URL url = path.toUri().toURL(); Map<String, Translation> translations = null; if (path.endsWith(".json")) { translations = getFromJson(url); } else if (path.endsWith(".lang")) { translations = getFromProperties(url); } if (translations != null && !translations.isEmpty()) { registry.register(locale, translations); logger.debug("Loaded " + translations.size() + " translations for " + locale); any.set(true); } } catch (Throwable t) { logger.warning("Failed to read language file " + fileName, t); } }); } } private Map<String, Translation> getFromProperties(URL url) throws IOException { Map<String, Translation> translations = new HashMap<>(); Properties properties = new Properties(); try (InputStream inputStream = url.openStream()) { properties.load(inputStream); } properties.forEach((k, v) -> translations.put((String) k, Translation.stringFormat((String) v))); return translations; } private Map<String, Translation> getFromJson(URL url) throws IOException { Map<String, Translation> translations = new HashMap<>(); JsonNode node = discordSRV.json().readTree(url); node.fields().forEachRemaining(entry -> translations.put( entry.getKey(), Translation.stringFormat(entry.getValue().textValue())) ); return translations; } private URL findResource(String name) { ClassLoader classLoader = getClass().getClassLoader(); URL url = null; while (classLoader != null && url == null) { url = classLoader.getResource(name); classLoader = classLoader.getParent(); } return url; } private void loadMCTranslations(AtomicBoolean any) { Map<String, Translation> translations = new HashMap<>(); try { URL enUS = findResource("assets/minecraft/lang/en_US.lang"); if (enUS == null) { enUS = findResource("assets/minecraft/lang/en_us.lang"); } if (enUS != null) { translations = getFromProperties(enUS); } } catch (Throwable t) { logger.debug("Failed to load locale", t); } try { URL enUS = findResource("assets/minecraft/lang/en_us.json"); if (enUS != null) { translations = getFromJson(enUS); } } catch (Throwable t) { logger.debug("Failed to load locale", t); } if (!translations.isEmpty()) { discordSRV.componentFactory().translationRegistry().register(Locale.US, translations); logger.debug("Found " + translations.size() + " Minecraft translations for en_us"); any.set(true); } } }
5,647
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitBanModule.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/ban/BukkitBanModule.java
package com.discordsrv.bukkit.ban; import com.discordsrv.api.module.type.PunishmentModule; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.logging.NamedLogger; import com.discordsrv.common.module.type.AbstractModule; import org.bukkit.BanEntry; import org.bukkit.BanList; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.time.Instant; import java.util.Date; import java.util.UUID; import java.util.concurrent.CompletableFuture; public class BukkitBanModule extends AbstractModule<BukkitDiscordSRV> implements PunishmentModule.Bans { public BukkitBanModule(BukkitDiscordSRV discordSRV) { super(discordSRV, new NamedLogger(discordSRV, "BUKKIT_BAN")); } @Override public CompletableFuture<Punishment> getBan(@NotNull UUID playerUUID) { CompletableFuture<BanEntry> entryFuture; if (PaperBanList.IS_AVAILABLE) { entryFuture = CompletableFuture.completedFuture(PaperBanList.getBanEntry(discordSRV.server(), playerUUID)); } else { BanList banList = discordSRV.server().getBanList(BanList.Type.NAME); entryFuture = discordSRV.playerProvider().lookupOfflinePlayer(playerUUID) .thenApply(offlinePlayer -> banList.getBanEntry(offlinePlayer.username())); } return entryFuture.thenApply(ban -> { Date expiration = ban.getExpiration(); return new PunishmentModule.Punishment(expiration != null ? expiration.toInstant() : null, ban.getReason(), ban.getSource()); }); } @Override public CompletableFuture<Void> addBan(@NotNull UUID playerUUID, @Nullable Instant until, @Nullable String reason, @NotNull String punisher) { if (PaperBanList.IS_AVAILABLE) { PaperBanList.addBan(discordSRV.server(), playerUUID, until, reason, punisher); return CompletableFuture.completedFuture(null); } BanList banList = discordSRV.server().getBanList(BanList.Type.NAME); return discordSRV.playerProvider().lookupOfflinePlayer(playerUUID).thenApply(offlinePlayer -> { banList.addBan(offlinePlayer.username(), reason, until != null ? Date.from(until) : null, punisher); return null; }); } @Override public CompletableFuture<Void> removeBan(@NotNull UUID playerUUID) { if (PaperBanList.IS_AVAILABLE) { PaperBanList.removeBan(discordSRV.server(), playerUUID); return CompletableFuture.completedFuture(null); } BanList banList = discordSRV.server().getBanList(BanList.Type.NAME); return discordSRV.playerProvider().lookupOfflinePlayer(playerUUID).thenApply(offlinePlayer -> { banList.pardon(offlinePlayer.username()); return null; }); } }
2,842
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitPlayerProvider.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitPlayerProvider.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.player; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.player.IOfflinePlayer; import com.discordsrv.common.player.IPlayer; import com.discordsrv.common.player.provider.ServerPlayerProvider; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; public class BukkitPlayerProvider extends ServerPlayerProvider<BukkitPlayer, BukkitDiscordSRV> implements Listener { public BukkitPlayerProvider(BukkitDiscordSRV discordSRV) { super(discordSRV); } // IPlayer @Override public void subscribe() { discordSRV.server().getPluginManager().registerEvents(this, discordSRV.plugin()); // Add players that are already connected for (Player player : discordSRV.server().getOnlinePlayers()) { addPlayer(player, true); } } @EventHandler(priority = EventPriority.MONITOR) public void onPlayerLogin(PlayerLoginEvent event) { addPlayer(event.getPlayer(), false); } private void addPlayer(Player player, boolean initial) { addPlayer(player.getUniqueId(), new BukkitPlayer(discordSRV, player), initial); } @EventHandler(priority = EventPriority.MONITOR) public void onPlayerQuit(PlayerQuitEvent event) { removePlayer(event.getPlayer().getUniqueId()); } public BukkitPlayer player(Player player) { BukkitPlayer srvPlayer = player(player.getUniqueId()); if (srvPlayer == null) { throw new IllegalStateException("Player not available"); } return srvPlayer; } // IOfflinePlayer private CompletableFuture<IOfflinePlayer> getFuture(Supplier<OfflinePlayer> provider) { return CompletableFuture.supplyAsync(() -> { OfflinePlayer offlinePlayer = provider.get(); if (offlinePlayer == null) { return null; } return new BukkitOfflinePlayer(discordSRV, offlinePlayer); }, discordSRV.scheduler().executor()); } @Override public CompletableFuture<IOfflinePlayer> lookupOfflinePlayer(UUID uuid) { IPlayer player = player(uuid); if (player != null) { return CompletableFuture.completedFuture(player); } return getFuture(() -> discordSRV.server().getOfflinePlayer(uuid)); } @SuppressWarnings("deprecation") // Shut up, I know @Override public CompletableFuture<IOfflinePlayer> lookupOfflinePlayer(String username) { IPlayer player = player(username); if (player != null) { return CompletableFuture.completedFuture(player); } return getFuture(() -> discordSRV.server().getOfflinePlayer(username)); } public IOfflinePlayer offlinePlayer(OfflinePlayer offlinePlayer) { return new BukkitOfflinePlayer(discordSRV, offlinePlayer); } }
4,029
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitPlayer.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitPlayer.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.player; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.bukkit.command.game.sender.BukkitCommandSender; import com.discordsrv.bukkit.component.PaperComponentHandle; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.component.util.ComponentUtil; import com.discordsrv.common.player.IPlayer; import com.discordsrv.common.player.provider.model.SkinInfo; import net.kyori.adventure.identity.Identity; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Locale; public class BukkitPlayer extends BukkitCommandSender implements IPlayer { private static final PaperComponentHandle<Player> DISPLAY_NAME_HANDLE = makeDisplayNameHandle(); private static PaperComponentHandle<Player> makeDisplayNameHandle() { return new PaperComponentHandle<>( Player.class, "displayName", Player::getDisplayName ); } private final Player player; private final Identity identity; public BukkitPlayer(BukkitDiscordSRV discordSRV, Player player) { super(discordSRV, player, () -> discordSRV.audiences().player(player)); this.player = player; this.identity = Identity.identity(player.getUniqueId()); } @Override public DiscordSRV discordSRV() { return discordSRV; } @Override public @NotNull String username() { return player.getName(); } @Override public @Nullable SkinInfo skinInfo() { return SpigotPlayer.getSkinInfo(player); } @Override public Locale locale() { return PaperPlayer.getLocale(player); } @Override public @NotNull Component displayName() { return ComponentUtil.fromAPI(DISPLAY_NAME_HANDLE.getComponent(player)); } @Override public @NotNull Identity identity() { return identity; } }
2,847
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitOfflinePlayer.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitOfflinePlayer.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.player; import com.discordsrv.bukkit.BukkitDiscordSRV; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.player.IOfflinePlayer; import com.discordsrv.common.player.provider.model.SkinInfo; import net.kyori.adventure.identity.Identity; import org.bukkit.OfflinePlayer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class BukkitOfflinePlayer implements IOfflinePlayer { protected final BukkitDiscordSRV discordSRV; private final OfflinePlayer offlinePlayer; private final Identity identity; public BukkitOfflinePlayer(BukkitDiscordSRV discordSRV, @NotNull OfflinePlayer offlinePlayer) { this.discordSRV = discordSRV; this.offlinePlayer = offlinePlayer; this.identity = Identity.identity(offlinePlayer.getUniqueId()); } @Override public DiscordSRV discordSRV() { return discordSRV; } @Override public String username() { return offlinePlayer.getName(); } @Override public @Nullable SkinInfo skinInfo() { return null; } @Override public @NotNull Identity identity() { return identity; } }
2,043
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
PaperChatListener.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/chat/PaperChatListener.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.listener.chat; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.bukkit.component.PaperComponentHandle; import io.papermc.paper.event.player.AsyncChatEvent; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; public class PaperChatListener implements Listener { private static final PaperComponentHandle<AsyncChatEvent> COMPONENT_HANDLE; static { COMPONENT_HANDLE = new PaperComponentHandle<>( AsyncChatEvent.class, "message", null ); } private final IBukkitChatForwarder listener; public PaperChatListener(IBukkitChatForwarder listener) { this.listener = listener; } @EventHandler(priority = EventPriority.MONITOR) public void onAsyncChat(AsyncChatEvent event) { MinecraftComponent component = COMPONENT_HANDLE.getComponent(event); listener.publishEvent(event, event.getPlayer(), component, event.isCancelled()); } }
1,896
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
IBukkitChatForwarder.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/chat/IBukkitChatForwarder.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.listener.chat; import com.discordsrv.api.component.MinecraftComponent; import org.bukkit.entity.Player; import org.bukkit.event.Event; public interface IBukkitChatForwarder { void publishEvent(Event event, Player player, MinecraftComponent component, boolean cancelled); }
1,140
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
PaperModernAdvancementListener.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/award/PaperModernAdvancementListener.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.listener.award; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.bukkit.component.PaperComponentHandle; import com.discordsrv.common.DiscordSRV; import io.papermc.paper.advancement.AdvancementDisplay; import org.bukkit.advancement.Advancement; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerAdvancementDoneEvent; public class PaperModernAdvancementListener extends AbstractBukkitAwardListener { private static final PaperComponentHandle<PlayerAdvancementDoneEvent> MESSAGE_HANDLE; private static final PaperComponentHandle<Advancement> DISPLAY_NAME_HANDLE; static { MESSAGE_HANDLE = new PaperComponentHandle<>( PlayerAdvancementDoneEvent.class, "message", null ); DISPLAY_NAME_HANDLE = new PaperComponentHandle<>( Advancement.class, "displayName", null ); } public PaperModernAdvancementListener(DiscordSRV discordSRV, IBukkitAwardForwarder forwarder) { super(discordSRV, forwarder); } @EventHandler(priority = EventPriority.MONITOR) public void onPlayerAdvancementDone(PlayerAdvancementDoneEvent event) { Advancement advancement = event.getAdvancement(); AdvancementDisplay display = advancement.getDisplay(); if (display == null || !display.doesAnnounceToChat()) { logger.trace("Skipping advancement display of \"" + advancement.getKey().getKey() + "\" for " + event.getPlayer() + ": advancement display == null or does not broadcast to chat"); return; } MinecraftComponent message = MESSAGE_HANDLE.getComponent(event); MinecraftComponent displayName = DISPLAY_NAME_HANDLE.getComponent(advancement); forwarder.publishEvent(event, event.getPlayer(), displayName, message, false); } }
2,833
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
PaperCommandMap.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/paper/src/main/java/com/discordsrv/bukkit/command/PaperCommandMap.java
package com.discordsrv.bukkit.command; import org.bukkit.Server; import java.util.Set; public class PaperCommandMap { public static final boolean IS_AVAILABLE; static { boolean is = false; try { Class<?> serverClass = Server.class; serverClass.getDeclaredMethod("getCommandMap"); is = true; } catch (Throwable ignored) {} IS_AVAILABLE = is; } public static Set<String> getKnownCommands(Server server) { return server.getCommandMap().getKnownCommands().keySet(); } }
568
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
PaperCommandFeedbackExecutor.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/paper/src/main/java/com/discordsrv/bukkit/console/executor/PaperCommandFeedbackExecutor.java
package com.discordsrv.bukkit.console.executor; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.common.component.util.ComponentUtil; import com.discordsrv.unrelocate.net.kyori.adventure.text.Component; import org.bukkit.Server; import org.bukkit.command.CommandSender; import java.util.function.Consumer; public class PaperCommandFeedbackExecutor implements Consumer<Component> { private final Consumer<MinecraftComponent> componentConsumer; private final CommandSender sender; @SuppressWarnings("unchecked") public PaperCommandFeedbackExecutor(Server server, Consumer<MinecraftComponent> componentConsumer) { this.componentConsumer = componentConsumer; this.sender = server.createCommandSender((Consumer<? super net.kyori.adventure.text.Component>) (Object) this); } public CommandSender sender() { return sender; } @Override public void accept(Component component) { MinecraftComponent minecraftComponent = ComponentUtil.fromUnrelocated(component); componentConsumer.accept(minecraftComponent); } }
1,118
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z
BukkitCommandFeedbackExecutorProxyTemplate.java
/FileExtraction/Java_unseen/DiscordSRV_Ascension/bukkit/paper/src/main/java/com/discordsrv/bukkit/console/executor/BukkitCommandFeedbackExecutorProxyTemplate.java
/* * This file is part of DiscordSRV, licensed under the GPLv3 License * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package com.discordsrv.bukkit.console.executor; import dev.vankka.dynamicproxy.processor.Original; import dev.vankka.dynamicproxy.processor.Proxy; import net.kyori.adventure.platform.bukkit.BukkitComponentSerializer; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer; import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.UUID; import java.util.function.Consumer; @SuppressWarnings("deprecation") // Paper @Proxy(value = CommandSender.class, className = "BukkitCommandFeedbackExecutorProxy") public abstract class BukkitCommandFeedbackExecutorProxyTemplate implements CommandSender { @Original private final CommandSender commandSender; private final Consumer<Component> componentConsumer; private Spigot spigot; public BukkitCommandFeedbackExecutorProxyTemplate(CommandSender commandSender, Consumer<Component> componentConsumer) { this.commandSender = commandSender; this.componentConsumer = componentConsumer; try { spigot = new Spigot(commandSender.spigot()); } catch (Throwable ignored) {} } @Override public void sendMessage(@Nullable UUID sender, @NotNull String... messages) { commandSender.sendMessage(sender, messages); forwardLegacy(String.join("\n", messages)); } @Override public void sendMessage(@NotNull String... messages) { commandSender.sendMessage(messages); forwardLegacy(String.join("\n", messages)); } @Override public void sendMessage(@Nullable UUID sender, @NotNull String message) { commandSender.sendMessage(sender, message); forwardLegacy(message); } @Override public void sendMessage(@NotNull String message) { commandSender.sendMessage(message); forwardLegacy(message); } private void forwardLegacy(String legacy) { componentConsumer.accept(BukkitComponentSerializer.legacy().deserialize(legacy)); } @Override public @NotNull CommandSender.Spigot spigot() { return spigot; } public class Spigot extends CommandSender.Spigot { private final CommandSender.Spigot spigot; Spigot(CommandSender.Spigot spigot) { this.spigot = spigot; } @Override public void sendMessage(@Nullable UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent component) { spigot.sendMessage(sender, component); forwardBungee(new net.md_5.bungee.api.chat.BaseComponent[] {component}); } @Override public void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent component) { spigot.sendMessage(component); forwardBungee(new net.md_5.bungee.api.chat.BaseComponent[] {component}); } @Override public void sendMessage(@Nullable UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent... components) { spigot.sendMessage(components); forwardBungee(components); } @Override public void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { spigot.sendMessage(components); forwardBungee(components); } private void forwardBungee(net.md_5.bungee.api.chat.BaseComponent[] components) { componentConsumer.accept(BungeeComponentSerializer.get().deserialize(components)); } } }
4,399
Java
.java
DiscordSRV/Ascension
17
3
1
2021-07-29T01:14:02Z
2024-05-08T00:28:36Z