diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d398d864..28282d40 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -10,20 +10,23 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/checkout@v4 + - name: Setup Java + uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: 17 cache: 'gradle' + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 - name: Build with Gradle run: ./gradlew build --no-daemon env: DISCORDSRV_AUTOTEST_BOT_TOKEN: ${{ secrets.DISCORDSRV_AUTOTEST_BOT_TOKEN }} DISCORDSRV_AUTOTEST_CHANNEL_ID: ${{ secrets.DISCORDSRV_AUTOTEST_CHANNEL_ID }} + DISCORDSRV_AUTOTEST_FORUM_ID: ${{ secrets.DISCORDSRV_AUTOTEST_FORUM_ID }} - name: Upload Build Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: build-artifacts path: "jars/*.jar" \ No newline at end of file diff --git a/.github/workflows/crowdin-download.yaml b/.github/workflows/crowdin-download.yaml index 8270df11..519f7f03 100644 --- a/.github/workflows/crowdin-download.yaml +++ b/.github/workflows/crowdin-download.yaml @@ -10,20 +10,21 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: - distribution: "adopt" - java-version: "17" - - name: Make gradlew executable - run: "sudo chmod +x gradlew" + distribution: 'temurin' + java-version: 17 + cache: 'gradle' + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 - name: Build i18n application run: "./gradlew i18n:build" - name: Generate translation source run: "java -jar i18n/build/libs/i18n-all.jar" - name: Download translations from Crowdin - uses: crowdin/github-action@v1 + uses: crowdin/github-action@v2 with: upload_sources: false upload_translations: false diff --git a/.github/workflows/crowdin-upload.yaml b/.github/workflows/crowdin-upload.yaml index f35cabb0..8bee85bb 100644 --- a/.github/workflows/crowdin-upload.yaml +++ b/.github/workflows/crowdin-upload.yaml @@ -9,20 +9,21 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: - distribution: "adopt" - java-version: "17" - - name: Make gradlew executable - run: "sudo chmod +x gradlew" + distribution: 'temurin' + java-version: 17 + cache: 'gradle' + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 - name: Build i18n application run: "./gradlew i18n:build" - name: Generate translation source run: "java -jar i18n/build/libs/i18n-all.jar" - name: Upload source to Crowdin - uses: crowdin/github-action@v1 + uses: crowdin/github-action@v2 with: upload_sources: true upload_translations: false diff --git a/.github/workflows/gradle-wrapper-validation.yaml b/.github/workflows/gradle-wrapper-validation.yaml index 7d4ca194..9cfe64da 100644 --- a/.github/workflows/gradle-wrapper-validation.yaml +++ b/.github/workflows/gradle-wrapper-validation.yaml @@ -1,4 +1,5 @@ -name: "Validate Gradle Wrapper" +name: Validate Gradle Wrapper + on: push: paths: ["gradle/wrapper/**"] @@ -10,5 +11,5 @@ jobs: name: "Validation" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: gradle/wrapper-validation-action@v1 + - uses: actions/checkout@v4 + - uses: gradle/actions/wrapper-validation@v3 diff --git a/.github/workflows/pr-dependency-review.yaml b/.github/workflows/pr-dependency-review.yaml index f2605b7a..85c13632 100644 --- a/.github/workflows/pr-dependency-review.yaml +++ b/.github/workflows/pr-dependency-review.yaml @@ -1,4 +1,5 @@ -name: 'Dependency Review' +name: Dependency Review + on: [pull_request] permissions: @@ -9,6 +10,6 @@ jobs: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Dependency Review' - uses: actions/dependency-review-action@v1 + uses: actions/dependency-review-action@v4 diff --git a/api/build.gradle b/api/build.gradle index 8de186a3..bd69b916 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -34,10 +34,10 @@ jar { from sourceSets.ap.output.resourcesDir } -//license { -// // Overwrite the default -// header = rootProject.file('buildscript/license/API_LICENSE_HEADER') -//} +indraSpotlessLicenser { + // Overwrite the default + licenseHeaderFile(rootProject.file('buildscript/license/API_LICENSE_HEADER')) +} publishing { publications { diff --git a/api/src/ap/java/com/discordsrv/api/processor/SubscribeProcessor.java b/api/src/ap/java/com/discordsrv/api/processor/SubscribeProcessor.java index 8038694b..e6549218 100644 --- a/api/src/ap/java/com/discordsrv/api/processor/SubscribeProcessor.java +++ b/api/src/ap/java/com/discordsrv/api/processor/SubscribeProcessor.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/DiscordSRVApi.java b/api/src/main/java/com/discordsrv/api/DiscordSRVApi.java index e5241b1c..6a17523f 100644 --- a/api/src/main/java/com/discordsrv/api/DiscordSRVApi.java +++ b/api/src/main/java/com/discordsrv/api/DiscordSRVApi.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/channel/GameChannel.java b/api/src/main/java/com/discordsrv/api/channel/GameChannel.java index 9e212aa3..597dfc4e 100644 --- a/api/src/main/java/com/discordsrv/api/channel/GameChannel.java +++ b/api/src/main/java/com/discordsrv/api/channel/GameChannel.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/color/Color.java b/api/src/main/java/com/discordsrv/api/color/Color.java index 0d8f687e..0f4d1212 100644 --- a/api/src/main/java/com/discordsrv/api/color/Color.java +++ b/api/src/main/java/com/discordsrv/api/color/Color.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/component/GameTextBuilder.java b/api/src/main/java/com/discordsrv/api/component/GameTextBuilder.java index 563777e0..36e44b42 100644 --- a/api/src/main/java/com/discordsrv/api/component/GameTextBuilder.java +++ b/api/src/main/java/com/discordsrv/api/component/GameTextBuilder.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/component/MinecraftComponent.java b/api/src/main/java/com/discordsrv/api/component/MinecraftComponent.java index b5f889d9..f062a06a 100644 --- a/api/src/main/java/com/discordsrv/api/component/MinecraftComponent.java +++ b/api/src/main/java/com/discordsrv/api/component/MinecraftComponent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/component/MinecraftComponentAdapter.java b/api/src/main/java/com/discordsrv/api/component/MinecraftComponentAdapter.java index de9e9ff1..bfa761d3 100644 --- a/api/src/main/java/com/discordsrv/api/component/MinecraftComponentAdapter.java +++ b/api/src/main/java/com/discordsrv/api/component/MinecraftComponentAdapter.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/component/MinecraftComponentFactory.java b/api/src/main/java/com/discordsrv/api/component/MinecraftComponentFactory.java index 1ace3056..fd7d9449 100644 --- a/api/src/main/java/com/discordsrv/api/component/MinecraftComponentFactory.java +++ b/api/src/main/java/com/discordsrv/api/component/MinecraftComponentFactory.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/DiscordAPI.java b/api/src/main/java/com/discordsrv/api/discord/DiscordAPI.java index f5a652d3..aa562af8 100644 --- a/api/src/main/java/com/discordsrv/api/discord/DiscordAPI.java +++ b/api/src/main/java/com/discordsrv/api/discord/DiscordAPI.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordCacheFlag.java b/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordCacheFlag.java index d2aef386..6ef44c00 100644 --- a/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordCacheFlag.java +++ b/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordCacheFlag.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordConnectionDetails.java b/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordConnectionDetails.java index 38baf232..ef25fa46 100644 --- a/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordConnectionDetails.java +++ b/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordConnectionDetails.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordGatewayIntent.java b/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordGatewayIntent.java index 427fc35c..07e7ad89 100644 --- a/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordGatewayIntent.java +++ b/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordGatewayIntent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 @@ -26,6 +26,8 @@ package com.discordsrv.api.discord.connection.details; import com.discordsrv.api.discord.entity.JDAEntity; import net.dv8tion.jda.api.requests.GatewayIntent; +import java.util.EnumSet; + public enum DiscordGatewayIntent implements JDAEntity { GUILD_MEMBERS(GatewayIntent.GUILD_MEMBERS, "Server Members Intent"), @@ -43,16 +45,31 @@ public enum DiscordGatewayIntent implements JDAEntity { DIRECT_MESSAGE_TYPING(GatewayIntent.DIRECT_MESSAGE_TYPING), MESSAGE_CONTENT(GatewayIntent.MESSAGE_CONTENT, "Message Content Intent"), SCHEDULED_EVENTS(GatewayIntent.SCHEDULED_EVENTS), + AUTO_MODERATION_CONFIGURATION(GatewayIntent.AUTO_MODERATION_CONFIGURATION), + AUTO_MODERATION_EXECUTION(GatewayIntent.AUTO_MODERATION_EXECUTION), ; - static DiscordGatewayIntent getByJda(GatewayIntent jda) { + public static final EnumSet PRIVILEGED; + + static { + EnumSet privileged = EnumSet.noneOf(DiscordGatewayIntent.class); + for (DiscordGatewayIntent intent : values()) { + if (intent.privileged()) { + privileged.add(intent); + } + } + + PRIVILEGED = privileged; + } + + public static DiscordGatewayIntent getByJda(GatewayIntent jda) { for (DiscordGatewayIntent value : values()) { if (value.asJDA() == jda) { return value; } } - throw new IllegalArgumentException("This intent does not have a "); + throw new IllegalArgumentException("This intent does not have a DiscordGatewayIntent"); } private final GatewayIntent jda; diff --git a/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordMemberCachePolicy.java b/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordMemberCachePolicy.java index 22d526be..b4b28ec4 100644 --- a/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordMemberCachePolicy.java +++ b/api/src/main/java/com/discordsrv/api/discord/connection/details/DiscordMemberCachePolicy.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/connection/jda/errorresponse/ErrorCallbackContext.java b/api/src/main/java/com/discordsrv/api/discord/connection/jda/errorresponse/ErrorCallbackContext.java index 45af0cb1..98897049 100644 --- a/api/src/main/java/com/discordsrv/api/discord/connection/jda/errorresponse/ErrorCallbackContext.java +++ b/api/src/main/java/com/discordsrv/api/discord/connection/jda/errorresponse/ErrorCallbackContext.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/DiscordUser.java b/api/src/main/java/com/discordsrv/api/discord/entity/DiscordUser.java index 5e96f08e..ef7f5146 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/DiscordUser.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/DiscordUser.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/JDAEntity.java b/api/src/main/java/com/discordsrv/api/discord/entity/JDAEntity.java index 9028daf7..77bf85d8 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/JDAEntity.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/JDAEntity.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/Mentionable.java b/api/src/main/java/com/discordsrv/api/discord/entity/Mentionable.java index 9e15f619..3fa5a155 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/Mentionable.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/Mentionable.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/Snowflake.java b/api/src/main/java/com/discordsrv/api/discord/entity/Snowflake.java index e71168e7..bfdf9bc9 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/Snowflake.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/Snowflake.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordChannel.java b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordChannel.java index 1804413c..718fb3ad 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordChannel.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordChannel.java @@ -1,3 +1,26 @@ +/* + * This file is part of the DiscordSRV API, licensed under the MIT License + * Copyright (c) 2016-2024 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.discord.entity.channel; import com.discordsrv.api.discord.entity.Snowflake; diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordChannelType.java b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordChannelType.java index de88fa6c..b0d4018b 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordChannelType.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordChannelType.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordDMChannel.java b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordDMChannel.java index d9b3f32c..822e35da 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordDMChannel.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordDMChannel.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordForumChannel.java b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordForumChannel.java index 4e241063..c1d3d5a4 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordForumChannel.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordForumChannel.java @@ -1,7 +1,35 @@ +/* + * This file is part of the DiscordSRV API, licensed under the MIT License + * Copyright (c) 2016-2024 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.discord.entity.channel; import com.discordsrv.api.discord.entity.JDAEntity; +import com.discordsrv.api.discord.entity.message.SendableDiscordMessage; import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel; +import java.util.concurrent.CompletableFuture; + public interface DiscordForumChannel extends DiscordChannel, DiscordThreadContainer, JDAEntity { + + CompletableFuture createPost(String name, SendableDiscordMessage message); } diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordGuildChannel.java b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordGuildChannel.java index 88178c10..59bdf073 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordGuildChannel.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordGuildChannel.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordGuildMessageChannel.java b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordGuildMessageChannel.java index b1308408..07b5e27e 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordGuildMessageChannel.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordGuildMessageChannel.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordMessageChannel.java b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordMessageChannel.java index 3b0e9a8c..ab863183 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordMessageChannel.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordMessageChannel.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordNewsChannel.java b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordNewsChannel.java index 9d4a25aa..635d49c8 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordNewsChannel.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordNewsChannel.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordStageChannel.java b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordStageChannel.java index d825c012..32598376 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordStageChannel.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordStageChannel.java @@ -1,3 +1,26 @@ +/* + * This file is part of the DiscordSRV API, licensed under the MIT License + * Copyright (c) 2016-2024 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.discord.entity.channel; import com.discordsrv.api.discord.entity.JDAEntity; diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordTextChannel.java b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordTextChannel.java index 116bf8e9..63d83f21 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordTextChannel.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordTextChannel.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordThreadChannel.java b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordThreadChannel.java index 792aa835..07d5a4b7 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordThreadChannel.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordThreadChannel.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordThreadContainer.java b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordThreadContainer.java index aafd5131..3d2b3845 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordThreadContainer.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordThreadContainer.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 @@ -23,6 +23,8 @@ package com.discordsrv.api.discord.entity.channel; +import com.discordsrv.api.DiscordSRVApi; +import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -42,4 +44,11 @@ public interface DiscordThreadContainer extends DiscordGuildChannel { CompletableFuture createThread(String name, boolean privateThread); CompletableFuture createThread(String name, long messageId); + + /** + * Returns the JDA representation of this object. This should not be used if it can be avoided. + * @return the JDA representation of this object + * @see DiscordSRVApi#jda() + */ + IThreadContainer getAsJDAThreadContainer(); } diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordVoiceChannel.java b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordVoiceChannel.java index 830525bf..b18642d4 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordVoiceChannel.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/channel/DiscordVoiceChannel.java @@ -1,3 +1,26 @@ +/* + * This file is part of the DiscordSRV API, licensed under the MIT License + * Copyright (c) 2016-2024 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.discord.entity.channel; import com.discordsrv.api.discord.entity.JDAEntity; diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordCustomEmoji.java b/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordCustomEmoji.java index b830c886..50343ed9 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordCustomEmoji.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordCustomEmoji.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordGuild.java b/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordGuild.java index 541e6433..1ad59765 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordGuild.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordGuild.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordGuildMember.java b/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordGuildMember.java index e1d427be..f7798fbd 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordGuildMember.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordGuildMember.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordRole.java b/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordRole.java index 83d874ea..992becb9 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordRole.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/guild/DiscordRole.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/DiscordInteractionHook.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/DiscordInteractionHook.java index 000602b6..1856a5a9 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/DiscordInteractionHook.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/DiscordInteractionHook.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/CommandOption.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/CommandOption.java index ccf20287..c6c07c07 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/CommandOption.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/CommandOption.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/CommandType.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/CommandType.java index 544ef1d8..ef217592 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/CommandType.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/CommandType.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/DiscordCommand.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/DiscordCommand.java index 56b00574..53fbc33d 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/DiscordCommand.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/DiscordCommand.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/SubCommandGroup.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/SubCommandGroup.java index bf9ea320..423702ff 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/SubCommandGroup.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/command/SubCommandGroup.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/ComponentIdentifier.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/ComponentIdentifier.java index 03075266..b44cd145 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/ComponentIdentifier.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/ComponentIdentifier.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/DiscordComponent.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/DiscordComponent.java index c74257bb..671ff34a 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/DiscordComponent.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/DiscordComponent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/MessageComponent.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/MessageComponent.java index f18d2933..4f61ed1e 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/MessageComponent.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/MessageComponent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/ModalComponent.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/ModalComponent.java index 9e6f4a3f..a87c024a 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/ModalComponent.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/ModalComponent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/actionrow/ActionRow.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/actionrow/ActionRow.java index bcfddfee..80073761 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/actionrow/ActionRow.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/actionrow/ActionRow.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/actionrow/MessageActionRow.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/actionrow/MessageActionRow.java index baec3b2c..fa5973ab 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/actionrow/MessageActionRow.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/actionrow/MessageActionRow.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/actionrow/ModalActionRow.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/actionrow/ModalActionRow.java index 0a9e8556..4a55fe97 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/actionrow/ModalActionRow.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/actionrow/ModalActionRow.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Button.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Button.java index dbc0fb71..65a03810 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Button.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Button.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Modal.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Modal.java index a43fc777..343d0f5c 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Modal.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/Modal.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/SelectMenu.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/SelectMenu.java index 3ddca623..ed47c399 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/SelectMenu.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/SelectMenu.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/TextInput.java b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/TextInput.java index 12ff7ea0..e5ed4b78 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/TextInput.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/interaction/component/impl/TextInput.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/message/AllowedMention.java b/api/src/main/java/com/discordsrv/api/discord/entity/message/AllowedMention.java index c5657a2e..16231122 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/message/AllowedMention.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/message/AllowedMention.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/message/DiscordMessageEmbed.java b/api/src/main/java/com/discordsrv/api/discord/entity/message/DiscordMessageEmbed.java index da5f7400..b6978a8f 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/message/DiscordMessageEmbed.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/message/DiscordMessageEmbed.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/message/ReceivedDiscordMessage.java b/api/src/main/java/com/discordsrv/api/discord/entity/message/ReceivedDiscordMessage.java index d5149182..2a36dcc7 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/message/ReceivedDiscordMessage.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/message/ReceivedDiscordMessage.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/message/ReceivedDiscordMessageCluster.java b/api/src/main/java/com/discordsrv/api/discord/entity/message/ReceivedDiscordMessageCluster.java index af026574..8e97d05f 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/message/ReceivedDiscordMessageCluster.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/message/ReceivedDiscordMessageCluster.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/message/SendableDiscordMessage.java b/api/src/main/java/com/discordsrv/api/discord/entity/message/SendableDiscordMessage.java index 84417261..6c0a9343 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/message/SendableDiscordMessage.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/message/SendableDiscordMessage.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/entity/message/impl/SendableDiscordMessageImpl.java b/api/src/main/java/com/discordsrv/api/discord/entity/message/impl/SendableDiscordMessageImpl.java index 08f56b08..252287cd 100644 --- a/api/src/main/java/com/discordsrv/api/discord/entity/message/impl/SendableDiscordMessageImpl.java +++ b/api/src/main/java/com/discordsrv/api/discord/entity/message/impl/SendableDiscordMessageImpl.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/exception/EntityNoLongerAvailableException.java b/api/src/main/java/com/discordsrv/api/discord/exception/EntityNoLongerAvailableException.java index 72e0dff2..bbc8254a 100644 --- a/api/src/main/java/com/discordsrv/api/discord/exception/EntityNoLongerAvailableException.java +++ b/api/src/main/java/com/discordsrv/api/discord/exception/EntityNoLongerAvailableException.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/exception/NotReadyException.java b/api/src/main/java/com/discordsrv/api/discord/exception/NotReadyException.java index f46dce0e..44b4cb22 100644 --- a/api/src/main/java/com/discordsrv/api/discord/exception/NotReadyException.java +++ b/api/src/main/java/com/discordsrv/api/discord/exception/NotReadyException.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/exception/RestErrorResponseException.java b/api/src/main/java/com/discordsrv/api/discord/exception/RestErrorResponseException.java index b70a91e7..0e3a943c 100644 --- a/api/src/main/java/com/discordsrv/api/discord/exception/RestErrorResponseException.java +++ b/api/src/main/java/com/discordsrv/api/discord/exception/RestErrorResponseException.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/discord/util/DiscordFormattingUtil.java b/api/src/main/java/com/discordsrv/api/discord/util/DiscordFormattingUtil.java index acb461de..ab5a2ff9 100644 --- a/api/src/main/java/com/discordsrv/api/discord/util/DiscordFormattingUtil.java +++ b/api/src/main/java/com/discordsrv/api/discord/util/DiscordFormattingUtil.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 @@ -23,10 +23,27 @@ package com.discordsrv.api.discord.util; +import java.util.Arrays; +import java.util.List; import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; public final class DiscordFormattingUtil { + // If first group is present the match will be ignored + private static final List FORMATTING_CHARACTERS = Arrays.asList('*', '_', '|', '`', '~', ':', '['); + private static final Pattern FORMATTING_PATTERN = Pattern.compile( + "(https?://.*\\.[^ ]*)?" + + "([" + + FORMATTING_CHARACTERS.stream() + .map(character -> Pattern.quote(String.valueOf(character))) + .collect(Collectors.joining()) + + "])" + ); + private static final Pattern QUOTE_PATTERN = Pattern.compile("(^|\n)>"); + private static final Pattern MENTION_PATTERN = Pattern.compile("(<[@#][0-9]{16,20}>)"); + private DiscordFormattingUtil() {} public static String escapeContent(String content) { @@ -37,23 +54,24 @@ public final class DiscordFormattingUtil { } public static String escapeFormatting(String content) { - return escapeChars(content, '*', '_', '|', '`', '~', ':', '['); - } - - private static String escapeChars(String input, char... characters) { - for (char character : characters) { - input = input.replace( - String.valueOf(character), - "\\" + character); + Matcher matcher = FORMATTING_PATTERN.matcher(content); + StringBuffer output = new StringBuffer(); + int lastEnd = 0; + while (matcher.find()) { + if (matcher.group(1) == null) { + matcher.appendReplacement(output, Matcher.quoteReplacement("\\" + matcher.group(2))); + lastEnd = matcher.end(); + } } - return input; + output.append(content.substring(lastEnd)); + return output.toString(); } public static String escapeQuotes(String input) { - return input.replaceAll("^>", Matcher.quoteReplacement("\\>")); + return QUOTE_PATTERN.matcher(input).replaceAll("$1" + Matcher.quoteReplacement("\\>")); } public static String escapeMentions(String input) { - return input.replaceAll("<([@#])", Matcher.quoteReplacement("\\<") + "$1"); + return MENTION_PATTERN.matcher(input).replaceAll(Matcher.quoteReplacement("\\") + "$1"); } } diff --git a/api/src/main/java/com/discordsrv/api/event/bus/EventBus.java b/api/src/main/java/com/discordsrv/api/event/bus/EventBus.java index a1b0f68d..ef9ab666 100644 --- a/api/src/main/java/com/discordsrv/api/event/bus/EventBus.java +++ b/api/src/main/java/com/discordsrv/api/event/bus/EventBus.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 @@ -28,6 +28,8 @@ import net.dv8tion.jda.api.events.GenericEvent; import org.jetbrains.annotations.Blocking; import org.jetbrains.annotations.NotNull; +import java.util.Collection; + /** * DiscordSRV's event bus, handling all events extending {@link Event}s and {@link GenericEvent}s. */ @@ -48,6 +50,14 @@ public interface EventBus { */ void unsubscribe(@NotNull Object eventListener); + /** + * Gets the listeners for a given event listener. + * + * @param eventListener an event listener that has valid {@link Subscribe} methods. + * @return a set of event listener in the provided class according to this {@link EventBus} + */ + Collection getListeners(@NotNull Object eventListener); + /** * Publishes a DiscordSRV {@link Event} to this {@link EventBus}. * diff --git a/api/src/main/java/com/discordsrv/api/event/bus/EventListener.java b/api/src/main/java/com/discordsrv/api/event/bus/EventListener.java index 039e9a22..174c5fde 100644 --- a/api/src/main/java/com/discordsrv/api/event/bus/EventListener.java +++ b/api/src/main/java/com/discordsrv/api/event/bus/EventListener.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 @@ -28,7 +28,7 @@ import org.jetbrains.annotations.NotNull; import java.lang.reflect.Method; /** - * A event listener. + * An event listener. */ @SuppressWarnings("unused") // API public interface EventListener { @@ -49,4 +49,11 @@ public interface EventListener { @NotNull String methodName(); + /** + * The event this listener is listening to. + * @return the event extending {@link com.discordsrv.api.event.events.Event} or {@link net.dv8tion.jda.api.events.GenericEvent} + */ + @NotNull + Class eventClass(); + } diff --git a/api/src/main/java/com/discordsrv/api/event/bus/EventPriority.java b/api/src/main/java/com/discordsrv/api/event/bus/EventPriority.java index 8f45f4f7..c4e63bf9 100644 --- a/api/src/main/java/com/discordsrv/api/event/bus/EventPriority.java +++ b/api/src/main/java/com/discordsrv/api/event/bus/EventPriority.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/bus/Subscribe.java b/api/src/main/java/com/discordsrv/api/event/bus/Subscribe.java index 6387ec88..03a0b51e 100644 --- a/api/src/main/java/com/discordsrv/api/event/bus/Subscribe.java +++ b/api/src/main/java/com/discordsrv/api/event/bus/Subscribe.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/bus/internal/EventStateHolder.java b/api/src/main/java/com/discordsrv/api/event/bus/internal/EventStateHolder.java index e57fe395..a0d98827 100644 --- a/api/src/main/java/com/discordsrv/api/event/bus/internal/EventStateHolder.java +++ b/api/src/main/java/com/discordsrv/api/event/bus/internal/EventStateHolder.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 @@ -50,5 +50,10 @@ public final class EventStateHolder { public @NotNull String methodName() { return null; } + + @Override + public @NotNull Class eventClass() { + return null; + } } } diff --git a/api/src/main/java/com/discordsrv/api/event/events/Cancellable.java b/api/src/main/java/com/discordsrv/api/event/events/Cancellable.java index 9b43af57..23ccb3e1 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/Cancellable.java +++ b/api/src/main/java/com/discordsrv/api/event/events/Cancellable.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/Event.java b/api/src/main/java/com/discordsrv/api/event/events/Event.java index 3fa44430..3cd217e0 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/Event.java +++ b/api/src/main/java/com/discordsrv/api/event/events/Event.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/PlayerEvent.java b/api/src/main/java/com/discordsrv/api/event/events/PlayerEvent.java index 96767a89..d07c16d5 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/PlayerEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/PlayerEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/Processable.java b/api/src/main/java/com/discordsrv/api/event/events/Processable.java index 02093b8e..df27b655 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/Processable.java +++ b/api/src/main/java/com/discordsrv/api/event/events/Processable.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/channel/GameChannelLookupEvent.java b/api/src/main/java/com/discordsrv/api/event/events/channel/GameChannelLookupEvent.java index f640b25f..a07a1a93 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/channel/GameChannelLookupEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/channel/GameChannelLookupEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/AbstractDiscordEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/AbstractDiscordEvent.java index 0441b131..c9db14aa 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/AbstractDiscordEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/AbstractDiscordEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/DiscordEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/DiscordEvent.java index 5071ccf0..51fdd879 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/DiscordEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/DiscordEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractDeferrableInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractDeferrableInteractionEvent.java index 0febdaf6..993283bc 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractDeferrableInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractDeferrableInteractionEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractInteractionEvent.java index 8d84bf22..1dcab08b 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/AbstractInteractionEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/DiscordModalInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/DiscordModalInteractionEvent.java index 04ec14fe..fa3badda 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/DiscordModalInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/DiscordModalInteractionEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/AbstractCommandInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/AbstractCommandInteractionEvent.java index 1a9e3d3d..e9e3a638 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/AbstractCommandInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/AbstractCommandInteractionEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/CommandRegisterEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/CommandRegisterEvent.java index e5d6c3bc..6e9ae37c 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/CommandRegisterEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/CommandRegisterEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordChatInputInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordChatInputInteractionEvent.java index 61a1dc9a..381d92d4 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordChatInputInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordChatInputInteractionEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordCommandAutoCompleteInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordCommandAutoCompleteInteractionEvent.java index f70f965a..605de7f6 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordCommandAutoCompleteInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordCommandAutoCompleteInteractionEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordMessageContextInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordMessageContextInteractionEvent.java index 2758808e..768d542b 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordMessageContextInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordMessageContextInteractionEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordUserContextInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordUserContextInteractionEvent.java index 5a7a8e4f..fadafec8 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordUserContextInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/command/DiscordUserContextInteractionEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordButtonInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordButtonInteractionEvent.java index b75176b1..11866c03 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordButtonInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordButtonInteractionEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordSelectMenuInteractionEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordSelectMenuInteractionEvent.java index 942956e7..6d79e4c9 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordSelectMenuInteractionEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/interaction/component/DiscordSelectMenuInteractionEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/member/AbstractDiscordMemberEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/member/AbstractDiscordMemberEvent.java index 8331aa06..95a64206 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/member/AbstractDiscordMemberEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/member/AbstractDiscordMemberEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/AbstractDiscordMemberRoleChangeEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/AbstractDiscordMemberRoleChangeEvent.java index 4d9f95f3..d725d19c 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/AbstractDiscordMemberRoleChangeEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/AbstractDiscordMemberRoleChangeEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleAddEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleAddEvent.java index 76eefc27..bd6b971d 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleAddEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleAddEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleRemoveEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleRemoveEvent.java index 748f2318..347e1aeb 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleRemoveEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/member/role/DiscordMemberRoleRemoveEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/message/AbstractDiscordMessageEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/message/AbstractDiscordMessageEvent.java index 1aed976e..080884a3 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/message/AbstractDiscordMessageEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/message/AbstractDiscordMessageEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageDeleteEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageDeleteEvent.java index f16ee650..36ff218d 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageDeleteEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageDeleteEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageReceiveEvent.java index e783ef66..3a064aea 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageReceiveEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageUpdateEvent.java b/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageUpdateEvent.java index 0118c50d..2cb24041 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageUpdateEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/discord/message/DiscordMessageUpdateEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVConnectedEvent.java b/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVConnectedEvent.java index 989d8cda..8df620f0 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVConnectedEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVConnectedEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVReadyEvent.java b/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVReadyEvent.java index 380f8f84..36a4fc84 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVReadyEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVReadyEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVReloadedEvent.java b/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVReloadedEvent.java index 2b7b80d9..f4e4a848 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVReloadedEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVReloadedEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVShuttingDownEvent.java b/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVShuttingDownEvent.java index d0aa86f2..c3492d2c 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVShuttingDownEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/lifecycle/DiscordSRVShuttingDownEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/linking/AccountLinkedEvent.java b/api/src/main/java/com/discordsrv/api/event/events/linking/AccountLinkedEvent.java index 0b809010..18ee5a4c 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/linking/AccountLinkedEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/linking/AccountLinkedEvent.java @@ -1,3 +1,26 @@ +/* + * This file is part of the DiscordSRV API, licensed under the MIT License + * Copyright (c) 2016-2024 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.linking; import com.discordsrv.api.event.events.Event; diff --git a/api/src/main/java/com/discordsrv/api/event/events/linking/AccountUnlinkedEvent.java b/api/src/main/java/com/discordsrv/api/event/events/linking/AccountUnlinkedEvent.java index 106fccd0..064acb3d 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/linking/AccountUnlinkedEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/linking/AccountUnlinkedEvent.java @@ -1,3 +1,26 @@ +/* + * This file is part of the DiscordSRV API, licensed under the MIT License + * Copyright (c) 2016-2024 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.linking; import com.discordsrv.api.event.events.Event; diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/forward/discord/DiscordChatMessageForwardedEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/forward/discord/DiscordChatMessageForwardedEvent.java index fae1c8ad..2257ebe1 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/forward/discord/DiscordChatMessageForwardedEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/forward/discord/DiscordChatMessageForwardedEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/AbstractGameMessageForwardedEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/AbstractGameMessageForwardedEvent.java index d32a4d62..60da281b 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/AbstractGameMessageForwardedEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/AbstractGameMessageForwardedEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/AwardMessageForwardedEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/AwardMessageForwardedEvent.java index 509248f3..5a6f65d7 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/AwardMessageForwardedEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/AwardMessageForwardedEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/DeathMessageForwardedEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/DeathMessageForwardedEvent.java index a6e892f6..54a66a62 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/DeathMessageForwardedEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/DeathMessageForwardedEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/GameChatMessageForwardedEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/GameChatMessageForwardedEvent.java index 1d012aee..f4b54233 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/GameChatMessageForwardedEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/GameChatMessageForwardedEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/JoinMessageForwardedEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/JoinMessageForwardedEvent.java index 07ff6d1a..69db0826 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/JoinMessageForwardedEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/JoinMessageForwardedEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/LeaveMessageForwardedEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/LeaveMessageForwardedEvent.java index ed4e9056..b6a0f138 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/LeaveMessageForwardedEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/LeaveMessageForwardedEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/ServerSwitchMessageForwardedEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/ServerSwitchMessageForwardedEvent.java index 960b8bee..3c088980 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/ServerSwitchMessageForwardedEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/forward/game/ServerSwitchMessageForwardedEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/process/discord/DiscordChatMessageCustomEmojiRenderEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/process/discord/DiscordChatMessageCustomEmojiRenderEvent.java index a33a587a..5396b78f 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/process/discord/DiscordChatMessageCustomEmojiRenderEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/process/discord/DiscordChatMessageCustomEmojiRenderEvent.java @@ -1,3 +1,26 @@ +/* + * This file is part of the DiscordSRV API, licensed under the MIT License + * Copyright (c) 2016-2024 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.process.discord; import com.discordsrv.api.component.MinecraftComponent; diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/process/discord/DiscordChatMessageProcessEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/process/discord/DiscordChatMessageProcessEvent.java index ce746357..8c8af692 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/process/discord/DiscordChatMessageProcessEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/process/discord/DiscordChatMessageProcessEvent.java @@ -1,3 +1,26 @@ +/* + * This file is part of the DiscordSRV API, licensed under the MIT License + * Copyright (c) 2016-2024 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.process.discord; import com.discordsrv.api.channel.GameChannel; diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/receive/discord/DiscordChatMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/receive/discord/DiscordChatMessageReceiveEvent.java index b0ab565e..5e56513e 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/receive/discord/DiscordChatMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/receive/discord/DiscordChatMessageReceiveEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/AbstractGameMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/AbstractGameMessageReceiveEvent.java index 565a3922..c4752d9a 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/AbstractGameMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/AbstractGameMessageReceiveEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/AwardMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/AwardMessageReceiveEvent.java index f3a32d14..5b6e17f1 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/AwardMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/AwardMessageReceiveEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/DeathMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/DeathMessageReceiveEvent.java index 043d8d77..95d3addf 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/DeathMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/DeathMessageReceiveEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/GameChatMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/GameChatMessageReceiveEvent.java index e4acfb19..d4849b20 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/GameChatMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/GameChatMessageReceiveEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/JoinMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/JoinMessageReceiveEvent.java index 99cc73c8..ab318715 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/JoinMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/JoinMessageReceiveEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/LeaveMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/LeaveMessageReceiveEvent.java index ca5541b0..20948a4c 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/LeaveMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/LeaveMessageReceiveEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/ServerSwitchMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/ServerSwitchMessageReceiveEvent.java index 47fcac64..a837a9ba 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/ServerSwitchMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/message/receive/game/ServerSwitchMessageReceiveEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/event/events/placeholder/PlaceholderLookupEvent.java b/api/src/main/java/com/discordsrv/api/event/events/placeholder/PlaceholderLookupEvent.java index a83f61be..8c14bdd2 100644 --- a/api/src/main/java/com/discordsrv/api/event/events/placeholder/PlaceholderLookupEvent.java +++ b/api/src/main/java/com/discordsrv/api/event/events/placeholder/PlaceholderLookupEvent.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/module/Module.java b/api/src/main/java/com/discordsrv/api/module/Module.java index d261cb68..0994d1fd 100644 --- a/api/src/main/java/com/discordsrv/api/module/Module.java +++ b/api/src/main/java/com/discordsrv/api/module/Module.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 @@ -27,10 +27,16 @@ import com.discordsrv.api.DiscordSRVApi; import com.discordsrv.api.discord.connection.details.DiscordCacheFlag; import com.discordsrv.api.discord.connection.details.DiscordGatewayIntent; import com.discordsrv.api.discord.connection.details.DiscordMemberCachePolicy; +import com.discordsrv.api.event.bus.EventListener; +import com.discordsrv.api.event.events.discord.message.AbstractDiscordMessageEvent; +import net.dv8tion.jda.api.events.GenericEvent; +import net.dv8tion.jda.api.events.guild.member.GenericGuildMemberEvent; +import net.dv8tion.jda.api.requests.GatewayIntent; import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.Collections; +import java.util.EnumSet; import java.util.function.Consumer; public interface Module { @@ -46,11 +52,55 @@ public interface Module { /** * Provides a {@link Collection} of {@link DiscordGatewayIntent}s that are required for this {@link Module}. + * This defaults to determining intents based on the events listened to in this class via {@link com.discordsrv.api.event.bus.Subscribe} methods. * @return the collection of gateway intents required by this module at the time this method is called */ + @SuppressWarnings("unchecked") // Class generic cast @NotNull default Collection requiredIntents() { - return Collections.emptyList(); + DiscordSRVApi api = DiscordSRVApi.get(); + if (api == null) { + return Collections.emptyList(); + } + + Collection listeners = api.eventBus().getListeners(this); + EnumSet intents = EnumSet.noneOf(DiscordGatewayIntent.class); + + for (EventListener listener : listeners) { + Class eventClass = listener.eventClass(); + + // DiscordSRV + if (AbstractDiscordMessageEvent.class.isAssignableFrom(eventClass)) { + intents.addAll(EnumSet.of(DiscordGatewayIntent.GUILD_MESSAGES, DiscordGatewayIntent.DIRECT_MESSAGES)); + } + if (GenericGuildMemberEvent.class.isAssignableFrom(eventClass)) { + intents.add(DiscordGatewayIntent.GUILD_MEMBERS); + } + + // JDA + if (!GenericEvent.class.isAssignableFrom(eventClass)) { + continue; + } + + EnumSet jdaIntents = GatewayIntent.fromEvents((Class) listener.eventClass()); + for (GatewayIntent jdaIntent : jdaIntents) { + try { + intents.add(DiscordGatewayIntent.getByJda(jdaIntent)); + } catch (IllegalArgumentException ignored) {} + } + } + + // Below are some intents that will not be added by event reference (and have to be specified intentionally) + + // Direct messages are rarely used by bots (and Guild & Direct message events are the same) + intents.remove(DiscordGatewayIntent.DIRECT_MESSAGES); + intents.remove(DiscordGatewayIntent.DIRECT_MESSAGE_REACTIONS); + intents.remove(DiscordGatewayIntent.DIRECT_MESSAGE_TYPING); + + // Presences change A LOT + intents.remove(DiscordGatewayIntent.GUILD_PRESENCES); + + return intents; } /** diff --git a/api/src/main/java/com/discordsrv/api/module/type/NicknameModule.java b/api/src/main/java/com/discordsrv/api/module/type/NicknameModule.java index ef93608b..a963227c 100644 --- a/api/src/main/java/com/discordsrv/api/module/type/NicknameModule.java +++ b/api/src/main/java/com/discordsrv/api/module/type/NicknameModule.java @@ -1,3 +1,26 @@ +/* + * This file is part of the DiscordSRV API, licensed under the MIT License + * Copyright (c) 2016-2024 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.module.type; import java.util.UUID; diff --git a/api/src/main/java/com/discordsrv/api/module/type/PermissionModule.java b/api/src/main/java/com/discordsrv/api/module/type/PermissionModule.java index ec6cc601..bb13f6b1 100644 --- a/api/src/main/java/com/discordsrv/api/module/type/PermissionModule.java +++ b/api/src/main/java/com/discordsrv/api/module/type/PermissionModule.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/module/type/PunishmentModule.java b/api/src/main/java/com/discordsrv/api/module/type/PunishmentModule.java index de9b9f3d..353e39d4 100644 --- a/api/src/main/java/com/discordsrv/api/module/type/PunishmentModule.java +++ b/api/src/main/java/com/discordsrv/api/module/type/PunishmentModule.java @@ -1,3 +1,26 @@ +/* + * This file is part of the DiscordSRV API, licensed under the MIT License + * Copyright (c) 2016-2024 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.module.type; import com.discordsrv.api.module.Module; diff --git a/api/src/main/java/com/discordsrv/api/placeholder/FormattedText.java b/api/src/main/java/com/discordsrv/api/placeholder/FormattedText.java index 63bc13b2..c39f124c 100644 --- a/api/src/main/java/com/discordsrv/api/placeholder/FormattedText.java +++ b/api/src/main/java/com/discordsrv/api/placeholder/FormattedText.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/placeholder/PlaceholderLookupResult.java b/api/src/main/java/com/discordsrv/api/placeholder/PlaceholderLookupResult.java index 6f9c5144..e1938102 100644 --- a/api/src/main/java/com/discordsrv/api/placeholder/PlaceholderLookupResult.java +++ b/api/src/main/java/com/discordsrv/api/placeholder/PlaceholderLookupResult.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/placeholder/PlaceholderService.java b/api/src/main/java/com/discordsrv/api/placeholder/PlaceholderService.java index bf8d8e96..dccf9649 100644 --- a/api/src/main/java/com/discordsrv/api/placeholder/PlaceholderService.java +++ b/api/src/main/java/com/discordsrv/api/placeholder/PlaceholderService.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/placeholder/PlainPlaceholderFormat.java b/api/src/main/java/com/discordsrv/api/placeholder/PlainPlaceholderFormat.java index 41c27c63..ea4bc17f 100644 --- a/api/src/main/java/com/discordsrv/api/placeholder/PlainPlaceholderFormat.java +++ b/api/src/main/java/com/discordsrv/api/placeholder/PlainPlaceholderFormat.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/placeholder/annotation/Placeholder.java b/api/src/main/java/com/discordsrv/api/placeholder/annotation/Placeholder.java index f98711c0..b271c399 100644 --- a/api/src/main/java/com/discordsrv/api/placeholder/annotation/Placeholder.java +++ b/api/src/main/java/com/discordsrv/api/placeholder/annotation/Placeholder.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/placeholder/annotation/PlaceholderPrefix.java b/api/src/main/java/com/discordsrv/api/placeholder/annotation/PlaceholderPrefix.java index 37d57f6c..b3b54cb2 100644 --- a/api/src/main/java/com/discordsrv/api/placeholder/annotation/PlaceholderPrefix.java +++ b/api/src/main/java/com/discordsrv/api/placeholder/annotation/PlaceholderPrefix.java @@ -1,3 +1,26 @@ +/* + * This file is part of the DiscordSRV API, licensed under the MIT License + * Copyright (c) 2016-2024 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.placeholder.annotation; import java.lang.annotation.ElementType; diff --git a/api/src/main/java/com/discordsrv/api/placeholder/annotation/PlaceholderRemainder.java b/api/src/main/java/com/discordsrv/api/placeholder/annotation/PlaceholderRemainder.java index e47ccb1c..1525e942 100644 --- a/api/src/main/java/com/discordsrv/api/placeholder/annotation/PlaceholderRemainder.java +++ b/api/src/main/java/com/discordsrv/api/placeholder/annotation/PlaceholderRemainder.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/placeholder/mapper/PlaceholderResultMapper.java b/api/src/main/java/com/discordsrv/api/placeholder/mapper/PlaceholderResultMapper.java index 60ac24c3..5ccb368f 100644 --- a/api/src/main/java/com/discordsrv/api/placeholder/mapper/PlaceholderResultMapper.java +++ b/api/src/main/java/com/discordsrv/api/placeholder/mapper/PlaceholderResultMapper.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/placeholder/provider/PlaceholderProvider.java b/api/src/main/java/com/discordsrv/api/placeholder/provider/PlaceholderProvider.java index d0e25531..0e0c8c34 100644 --- a/api/src/main/java/com/discordsrv/api/placeholder/provider/PlaceholderProvider.java +++ b/api/src/main/java/com/discordsrv/api/placeholder/provider/PlaceholderProvider.java @@ -1,19 +1,24 @@ /* - * 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 file is part of the DiscordSRV API, licensed under the MIT License + * Copyright (c) 2016-2024 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. + * 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: * - * 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. + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * 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.placeholder.provider; diff --git a/api/src/main/java/com/discordsrv/api/placeholder/provider/SinglePlaceholder.java b/api/src/main/java/com/discordsrv/api/placeholder/provider/SinglePlaceholder.java index eba70b0a..d1d491e7 100644 --- a/api/src/main/java/com/discordsrv/api/placeholder/provider/SinglePlaceholder.java +++ b/api/src/main/java/com/discordsrv/api/placeholder/provider/SinglePlaceholder.java @@ -1,3 +1,26 @@ +/* + * This file is part of the DiscordSRV API, licensed under the MIT License + * Copyright (c) 2016-2024 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.placeholder.provider; import com.discordsrv.api.placeholder.PlaceholderLookupResult; diff --git a/api/src/main/java/com/discordsrv/api/placeholder/util/Placeholders.java b/api/src/main/java/com/discordsrv/api/placeholder/util/Placeholders.java index cf95149b..2bbc2fc4 100644 --- a/api/src/main/java/com/discordsrv/api/placeholder/util/Placeholders.java +++ b/api/src/main/java/com/discordsrv/api/placeholder/util/Placeholders.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/player/DiscordSRVPlayer.java b/api/src/main/java/com/discordsrv/api/player/DiscordSRVPlayer.java index 98c83cfe..94ea989d 100644 --- a/api/src/main/java/com/discordsrv/api/player/DiscordSRVPlayer.java +++ b/api/src/main/java/com/discordsrv/api/player/DiscordSRVPlayer.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/player/IPlayerProvider.java b/api/src/main/java/com/discordsrv/api/player/IPlayerProvider.java index ebc50d87..e2352dc9 100644 --- a/api/src/main/java/com/discordsrv/api/player/IPlayerProvider.java +++ b/api/src/main/java/com/discordsrv/api/player/IPlayerProvider.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/profile/IProfile.java b/api/src/main/java/com/discordsrv/api/profile/IProfile.java index 05cfce6e..141c4507 100644 --- a/api/src/main/java/com/discordsrv/api/profile/IProfile.java +++ b/api/src/main/java/com/discordsrv/api/profile/IProfile.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/main/java/com/discordsrv/api/profile/IProfileManager.java b/api/src/main/java/com/discordsrv/api/profile/IProfileManager.java index 52438182..b090e243 100644 --- a/api/src/main/java/com/discordsrv/api/profile/IProfileManager.java +++ b/api/src/main/java/com/discordsrv/api/profile/IProfileManager.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/api/src/test/java/com/discordsrv/api/placeholder/util/PlaceholdersTest.java b/api/src/test/java/com/discordsrv/api/placeholder/util/PlaceholdersTest.java index 9ead7147..387e9362 100644 --- a/api/src/test/java/com/discordsrv/api/placeholder/util/PlaceholdersTest.java +++ b/api/src/test/java/com/discordsrv/api/placeholder/util/PlaceholdersTest.java @@ -1,6 +1,6 @@ /* * 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 + * Copyright (c) 2016-2024 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 diff --git a/build.gradle b/build.gradle index 195f1096..5e84b7f2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,10 @@ plugins { alias(libs.plugins.shadow) apply false - alias(libs.plugins.licenser) apply false alias(libs.plugins.blossom) apply false alias(libs.plugins.indra.git) apply false + alias(libs.plugins.indra.licenser) apply false alias(libs.plugins.dependencydownload.plugin) apply false + alias(libs.plugins.idea.ext) apply false } version '3.0.0-SNAPSHOT' @@ -12,9 +13,9 @@ subprojects { apply plugin: 'java' apply plugin: 'java-library' apply plugin: 'idea' - apply plugin: 'com.github.johnrengelman.shadow' - //apply plugin: 'org.cadixdev.licenser' + apply plugin: 'io.github.goooler.shadow' apply plugin: 'net.kyori.indra.git' + apply plugin: 'net.kyori.indra.licenser.spotless' apply plugin: 'dev.vankka.dependencydownload.plugin' group 'com.discordsrv' @@ -90,8 +91,8 @@ subprojects { dependencies { // Test dependencies - testImplementation(libs.jupiter.api) - testRuntimeOnly(libs.jupiter.engine) + testImplementation(libs.junit.jupiter) + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' // DynamicProxy annotationProcessor(libs.dynamicproxy.api) @@ -99,6 +100,10 @@ subprojects { test { useJUnitPlatform() + + testLogging { + exceptionFormat = 'full' + } } tasks.register('deleteJarsDir', Delete) { @@ -111,7 +116,7 @@ subprojects { duplicatesStrategy = DuplicatesStrategy.INCLUDE // If CI then check that licenses are correct, otherwise automatically apply licenses on build -// dependsOn (System.getenv('CI') === 'true' ? licenseCheck : licenseFormat) + dependsOn (System.getenv('CI') === 'true' ? spotlessCheck : spotlessApply) // Always run shadowJar finalizedBy shadowJar @@ -158,7 +163,8 @@ subprojects { gradle.projectsEvaluated { tasks.withType(JavaCompile) { // Enable compiler warnings for unchecked & deprecation - options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' + // Disable compiler warning for source/target 8 + options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' << '-Xlint:-options' } } @@ -166,15 +172,10 @@ subprojects { duplicatesStrategy = DuplicatesStrategy.EXCLUDE } - -// license { -// header = rootProject.file('buildscript/license/LICENSE_HEADER') -// properties { -// var inception = '2016' -// var currentYear = String.valueOf(Calendar.getInstance().get(Calendar.YEAR)) -// -// year = inception == currentYear ? currentYear : inception + '-' + currentYear -// } -// include '**/*.java' // only java files -// } + indraSpotlessLicenser { + licenseHeaderFile(rootProject.file('buildscript/license/LICENSE_HEADER')) + newLine(true) + property('inception', '2016') + property('year_now', String.valueOf(Calendar.getInstance().get(Calendar.YEAR))) + } } diff --git a/buildscript/license/API_LICENSE_HEADER b/buildscript/license/API_LICENSE_HEADER index edb923b8..5aec88b5 100644 --- a/buildscript/license/API_LICENSE_HEADER +++ b/buildscript/license/API_LICENSE_HEADER @@ -1,5 +1,5 @@ This file is part of the DiscordSRV API, licensed under the MIT License -Copyright (c) ${year} Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors +Copyright (c) $inception-$year_now 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 diff --git a/buildscript/license/LICENSE_HEADER b/buildscript/license/LICENSE_HEADER index af86d2fb..767eda9f 100644 --- a/buildscript/license/LICENSE_HEADER +++ b/buildscript/license/LICENSE_HEADER @@ -1,5 +1,5 @@ This file is part of DiscordSRV, licensed under the GPLv3 License -Copyright (c) ${year} Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors +Copyright (c) $inception-$year_now 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 diff --git a/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/AbstractBukkitAwardListener.java b/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/AbstractBukkitAwardListener.java index dbde3360..4819cb4e 100644 --- a/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/AbstractBukkitAwardListener.java +++ b/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/AbstractBukkitAwardListener.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/BukkitLegacyAdvancementListener.java b/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/BukkitLegacyAdvancementListener.java index c0a58ec1..68d55b84 100644 --- a/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/BukkitLegacyAdvancementListener.java +++ b/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/BukkitLegacyAdvancementListener.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/IBukkitAwardForwarder.java b/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/IBukkitAwardForwarder.java index b5a181fb..e800e431 100644 --- a/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/IBukkitAwardForwarder.java +++ b/bukkit/bukkit1_12/src/main/java/com/discordsrv/bukkit/listener/award/IBukkitAwardForwarder.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/folia/build.gradle b/bukkit/folia/build.gradle index 633e612d..49e732e8 100644 --- a/bukkit/folia/build.gradle +++ b/bukkit/folia/build.gradle @@ -1,4 +1,6 @@ -disableAutoTargetJvm() // Requires Java 17, we target 8 +java { + disableAutoTargetJvm() // Requires Java 17, we target 8 +} dependencies { // Platform diff --git a/bukkit/folia/src/main/java/com/discordsrv/bukkit/scheduler/IBukkitScheduler.java b/bukkit/folia/src/main/java/com/discordsrv/bukkit/scheduler/IBukkitScheduler.java index 4e2b4ebf..082f09f4 100644 --- a/bukkit/folia/src/main/java/com/discordsrv/bukkit/scheduler/IBukkitScheduler.java +++ b/bukkit/folia/src/main/java/com/discordsrv/bukkit/scheduler/IBukkitScheduler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -18,11 +18,14 @@ package com.discordsrv.bukkit.scheduler; +import com.discordsrv.common.function.CheckedSupplier; +import com.discordsrv.common.future.util.CompletableFutureUtil; import com.discordsrv.common.scheduler.ServerScheduler; import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.plugin.Plugin; +import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; public interface IBukkitScheduler extends ServerScheduler { @@ -33,4 +36,12 @@ public interface IBukkitScheduler extends ServerScheduler { runOnMainThread(task); } + default CompletableFuture executeOnMainThread(CommandSender sender, Runnable runnable) { + return CompletableFuture.runAsync(runnable, task -> runOnMainThread(sender, task)); + } + + default CompletableFuture supplyOnMainThread(CommandSender sender, CheckedSupplier supplier) { + return CompletableFutureUtil.supplyAsync(supplier, task -> runOnMainThread(sender, task)); + } + } diff --git a/bukkit/folia/src/main/java/com/discordsrv/bukkit/scheduler/IFoliaScheduler.java b/bukkit/folia/src/main/java/com/discordsrv/bukkit/scheduler/IFoliaScheduler.java index 41fa4d2c..9d04b24b 100644 --- a/bukkit/folia/src/main/java/com/discordsrv/bukkit/scheduler/IFoliaScheduler.java +++ b/bukkit/folia/src/main/java/com/discordsrv/bukkit/scheduler/IFoliaScheduler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -23,6 +23,7 @@ import org.bukkit.command.BlockCommandSender; import org.bukkit.command.CommandSender; import org.bukkit.command.ProxiedCommandSender; import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; public interface IFoliaScheduler extends ServerScheduler, IBukkitScheduler { @@ -51,17 +52,17 @@ public interface IFoliaScheduler extends ServerScheduler, IBukkitScheduler { } @Override - default void runOnMainThread(Runnable task) { + default void runOnMainThread(@NotNull Runnable task) { runWithArgs((server, plugin) -> server.getGlobalRegionScheduler().execute(plugin, task)); } @Override - default void runOnMainThreadLaterInTicks(Runnable task, int ticks) { + default void runOnMainThreadLaterInTicks(@NotNull 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) { + default void runOnMainThreadAtFixedRateInTicks(@NotNull Runnable task, int initialTicks, int rateTicks) { runWithArgs((server, plugin) -> server.getGlobalRegionScheduler().execute(plugin, task)); } } diff --git a/bukkit/loader/src/main/java/com/discordsrv/bukkit/loader/DiscordSRVBukkitLoader.java b/bukkit/loader/src/main/java/com/discordsrv/bukkit/loader/DiscordSRVBukkitLoader.java index 13251a23..0ab34dda 100644 --- a/bukkit/loader/src/main/java/com/discordsrv/bukkit/loader/DiscordSRVBukkitLoader.java +++ b/bukkit/loader/src/main/java/com/discordsrv/bukkit/loader/DiscordSRVBukkitLoader.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/loader/src/main/resources/plugin.yml b/bukkit/loader/src/main/resources/plugin.yml index 27441489..7b5f42eb 100644 --- a/bukkit/loader/src/main/resources/plugin.yml +++ b/bukkit/loader/src/main/resources/plugin.yml @@ -18,7 +18,7 @@ softdepend: [ # Chat Chatty, LunaChat, TownyChat, VentureChat, # Other integrations - PlaceholderAPI, + PlaceholderAPI, Essentials, # Adventure ViaVersion ] diff --git a/bukkit/paper/build.gradle b/bukkit/paper/build.gradle index 29ddc418..be85924f 100644 --- a/bukkit/paper/build.gradle +++ b/bukkit/paper/build.gradle @@ -1,4 +1,6 @@ -disableAutoTargetJvm() // Requires Java 17, we target 8 +java { + disableAutoTargetJvm() // Requires Java 17, we target 8 +} dependencies { // Platform diff --git a/bukkit/paper/src/main/java/com/discordsrv/bukkit/ban/PaperBanList.java b/bukkit/paper/src/main/java/com/discordsrv/bukkit/ban/PaperBanList.java index d971b604..7eb07b26 100644 --- a/bukkit/paper/src/main/java/com/discordsrv/bukkit/ban/PaperBanList.java +++ b/bukkit/paper/src/main/java/com/discordsrv/bukkit/ban/PaperBanList.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.bukkit.ban; import org.bukkit.BanEntry; diff --git a/bukkit/paper/src/main/java/com/discordsrv/bukkit/command/PaperCommandMap.java b/bukkit/paper/src/main/java/com/discordsrv/bukkit/command/PaperCommandMap.java index 9f0b0d8d..3d8cc351 100644 --- a/bukkit/paper/src/main/java/com/discordsrv/bukkit/command/PaperCommandMap.java +++ b/bukkit/paper/src/main/java/com/discordsrv/bukkit/command/PaperCommandMap.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.bukkit.command; import org.bukkit.Server; diff --git a/bukkit/paper/src/main/java/com/discordsrv/bukkit/component/PaperComponentHandle.java b/bukkit/paper/src/main/java/com/discordsrv/bukkit/component/PaperComponentHandle.java index e28a3e17..ee3c9bc5 100644 --- a/bukkit/paper/src/main/java/com/discordsrv/bukkit/component/PaperComponentHandle.java +++ b/bukkit/paper/src/main/java/com/discordsrv/bukkit/component/PaperComponentHandle.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/paper/src/main/java/com/discordsrv/bukkit/console/executor/BukkitCommandFeedbackExecutorProxyTemplate.java b/bukkit/paper/src/main/java/com/discordsrv/bukkit/console/executor/BukkitCommandFeedbackExecutorProxyTemplate.java index 3eda59c5..46d936fe 100644 --- a/bukkit/paper/src/main/java/com/discordsrv/bukkit/console/executor/BukkitCommandFeedbackExecutorProxyTemplate.java +++ b/bukkit/paper/src/main/java/com/discordsrv/bukkit/console/executor/BukkitCommandFeedbackExecutorProxyTemplate.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/paper/src/main/java/com/discordsrv/bukkit/console/executor/PaperCommandFeedbackExecutor.java b/bukkit/paper/src/main/java/com/discordsrv/bukkit/console/executor/PaperCommandFeedbackExecutor.java index ce0baacd..a6127599 100644 --- a/bukkit/paper/src/main/java/com/discordsrv/bukkit/console/executor/PaperCommandFeedbackExecutor.java +++ b/bukkit/paper/src/main/java/com/discordsrv/bukkit/console/executor/PaperCommandFeedbackExecutor.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.bukkit.console.executor; import com.discordsrv.api.component.MinecraftComponent; diff --git a/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/award/PaperModernAdvancementListener.java b/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/award/PaperModernAdvancementListener.java index 56cf424f..d15a92eb 100644 --- a/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/award/PaperModernAdvancementListener.java +++ b/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/award/PaperModernAdvancementListener.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/chat/IBukkitChatForwarder.java b/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/chat/IBukkitChatForwarder.java index 8f544928..f1f37f9a 100644 --- a/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/chat/IBukkitChatForwarder.java +++ b/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/chat/IBukkitChatForwarder.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/chat/PaperChatListener.java b/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/chat/PaperChatListener.java index 6dea906a..283e5022 100644 --- a/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/chat/PaperChatListener.java +++ b/bukkit/paper/src/main/java/com/discordsrv/bukkit/listener/chat/PaperChatListener.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/paper/src/main/java/com/discordsrv/bukkit/player/PaperPlayer.java b/bukkit/paper/src/main/java/com/discordsrv/bukkit/player/PaperPlayer.java index dbe9f7f9..0e748d54 100644 --- a/bukkit/paper/src/main/java/com/discordsrv/bukkit/player/PaperPlayer.java +++ b/bukkit/paper/src/main/java/com/discordsrv/bukkit/player/PaperPlayer.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.bukkit.player; import org.bukkit.entity.Player; diff --git a/bukkit/spigot/src/main/java/com/discordsrv/bukkit/listener/award/SpigotModernAdvancementListener.java b/bukkit/spigot/src/main/java/com/discordsrv/bukkit/listener/award/SpigotModernAdvancementListener.java index d12b0005..04118d21 100644 --- a/bukkit/spigot/src/main/java/com/discordsrv/bukkit/listener/award/SpigotModernAdvancementListener.java +++ b/bukkit/spigot/src/main/java/com/discordsrv/bukkit/listener/award/SpigotModernAdvancementListener.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.bukkit.listener.award; import com.discordsrv.api.component.MinecraftComponent; diff --git a/bukkit/spigot/src/main/java/com/discordsrv/bukkit/player/SpigotPlayer.java b/bukkit/spigot/src/main/java/com/discordsrv/bukkit/player/SpigotPlayer.java index 0e99e427..1acea94f 100644 --- a/bukkit/spigot/src/main/java/com/discordsrv/bukkit/player/SpigotPlayer.java +++ b/bukkit/spigot/src/main/java/com/discordsrv/bukkit/player/SpigotPlayer.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.bukkit.player; import com.discordsrv.common.player.provider.model.SkinInfo; diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java b/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java index b0b0ec78..b242509a 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/DiscordSRVBukkitBootstrap.java b/bukkit/src/main/java/com/discordsrv/bukkit/DiscordSRVBukkitBootstrap.java index 587835db..eb6c7791 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/DiscordSRVBukkitBootstrap.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/DiscordSRVBukkitBootstrap.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/ban/BukkitBanModule.java b/bukkit/src/main/java/com/discordsrv/bukkit/ban/BukkitBanModule.java index 4c7c0f3a..ca88ad0e 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/ban/BukkitBanModule.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/ban/BukkitBanModule.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.bukkit.ban; import com.discordsrv.api.module.type.PunishmentModule; diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/command/game/BukkitGameCommandExecutionHelper.java b/bukkit/src/main/java/com/discordsrv/bukkit/command/game/BukkitGameCommandExecutionHelper.java index da3d4a10..5383f4dc 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/command/game/BukkitGameCommandExecutionHelper.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/command/game/BukkitGameCommandExecutionHelper.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.bukkit.command.game; import com.discordsrv.bukkit.BukkitDiscordSRV; @@ -35,20 +53,14 @@ public class BukkitGameCommandExecutionHelper implements GameCommandExecutionHel if (PaperCommandMap.IS_AVAILABLE) { // If Paper's CommandMap is available we can list out 'root' commands - CompletableFuture> 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); - } + return discordSRV.scheduler().supplyOnMainThread(discordSRV.server().getConsoleSender(), () -> { + 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 suggestions; }); - return future; } return CompletableFuture.completedFuture(suggestions); @@ -57,24 +69,17 @@ public class BukkitGameCommandExecutionHelper implements GameCommandExecutionHel // Get the arguments minus the last one (if any) String prefix = parts.isEmpty() ? "" : String.join(" ", parts.subList(0, parts.size() - 1)) + " "; - CompletableFuture> future = new CompletableFuture<>(); CommandSender commandSender = discordSRV.server().getConsoleSender(); - discordSRV.scheduler().runOnMainThread(commandSender, () -> { - try { - List completions = command.tabComplete(commandSender, commandName, parts.toArray(new String[0])); + return discordSRV.scheduler().supplyOnMainThread(commandSender, () -> { + List completions = command.tabComplete(commandSender, commandName, parts.toArray(new String[0])); - List suggestions = new ArrayList<>(); - for (String suggestion : completions) { - suggestions.add(commandName + " " + prefix + suggestion); - } - future.complete(suggestions); - } catch (Throwable t) { - future.completeExceptionally(t); + List suggestions = new ArrayList<>(); + for (String suggestion : completions) { + suggestions.add(commandName + " " + prefix + suggestion); } + return suggestions; }); - - return future; } @Override diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/AbstractBukkitCommandExecutor.java b/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/AbstractBukkitCommandExecutor.java index 2340d1a9..6587ade1 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/AbstractBukkitCommandExecutor.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/AbstractBukkitCommandExecutor.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/AbstractBukkitCommandHandler.java b/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/AbstractBukkitCommandHandler.java index 0f390f6c..b98c88cb 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/AbstractBukkitCommandHandler.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/AbstractBukkitCommandHandler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/BukkitBasicCommandHandler.java b/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/BukkitBasicCommandHandler.java index 5be5102b..e1e01931 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/BukkitBasicCommandHandler.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/BukkitBasicCommandHandler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/CommodoreHandler.java b/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/CommodoreHandler.java index fab76307..40a73429 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/CommodoreHandler.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/command/game/handler/CommodoreHandler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/command/game/sender/BukkitCommandSender.java b/bukkit/src/main/java/com/discordsrv/bukkit/command/game/sender/BukkitCommandSender.java index f63f95d0..2a1b15b3 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/command/game/sender/BukkitCommandSender.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/command/game/sender/BukkitCommandSender.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/component/translation/BukkitTranslationLoader.java b/bukkit/src/main/java/com/discordsrv/bukkit/component/translation/BukkitTranslationLoader.java index 754502da..7c04e1a2 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/component/translation/BukkitTranslationLoader.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/component/translation/BukkitTranslationLoader.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.bukkit.component.translation; import com.discordsrv.bukkit.BukkitDiscordSRV; diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/config/connection/BukkitConnectionConfig.java b/bukkit/src/main/java/com/discordsrv/bukkit/config/connection/BukkitConnectionConfig.java index 0bddeb77..b95165d0 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/config/connection/BukkitConnectionConfig.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/config/connection/BukkitConnectionConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/config/main/BukkitConfig.java b/bukkit/src/main/java/com/discordsrv/bukkit/config/main/BukkitConfig.java index e8d34896..396c8450 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/config/main/BukkitConfig.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/config/main/BukkitConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/config/main/BukkitRequiredLinkingConfig.java b/bukkit/src/main/java/com/discordsrv/bukkit/config/main/BukkitRequiredLinkingConfig.java index 99b81e91..c735523a 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/config/main/BukkitRequiredLinkingConfig.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/config/main/BukkitRequiredLinkingConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitConfigManager.java b/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitConfigManager.java index c79078cb..886a51db 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitConfigManager.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitConfigManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitConnectionConfigManager.java b/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitConnectionConfigManager.java index ecc5f939..fb5313a3 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitConnectionConfigManager.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitConnectionConfigManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitMessagesConfigManager.java b/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitMessagesConfigManager.java index e00b3bad..6bdfa3f1 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitMessagesConfigManager.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/config/manager/BukkitMessagesConfigManager.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.bukkit.config.manager; import com.discordsrv.common.DiscordSRV; diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/console/BukkitConsole.java b/bukkit/src/main/java/com/discordsrv/bukkit/console/BukkitConsole.java index e9384bfc..7c1f1298 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/console/BukkitConsole.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/console/BukkitConsole.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/console/executor/BukkitCommandExecutorProvider.java b/bukkit/src/main/java/com/discordsrv/bukkit/console/executor/BukkitCommandExecutorProvider.java index 395b1af5..a88432ba 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/console/executor/BukkitCommandExecutorProvider.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/console/executor/BukkitCommandExecutorProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/console/executor/CommandSenderExecutor.java b/bukkit/src/main/java/com/discordsrv/bukkit/console/executor/CommandSenderExecutor.java index 35107610..618862e6 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/console/executor/CommandSenderExecutor.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/console/executor/CommandSenderExecutor.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/integration/EssentialsXIntegration.java b/bukkit/src/main/java/com/discordsrv/bukkit/integration/EssentialsXIntegration.java index 56ef6213..a86ec10d 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/integration/EssentialsXIntegration.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/integration/EssentialsXIntegration.java @@ -1,7 +1,26 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.bukkit.integration; 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; @@ -20,6 +39,7 @@ 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.HandlerList; import org.bukkit.event.Listener; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -54,12 +74,22 @@ public class EssentialsXIntegration return super.isEnabled(); } + @Override + public void enable() { + discordSRV.server().getPluginManager().registerEvents(this, discordSRV.plugin()); + } + + @Override + public void disable() { + HandlerList.unregisterAll(this); + } + private Essentials get() { return (Essentials) discordSRV.server().getPluginManager().getPlugin("Essentials"); } private CompletableFuture getUser(UUID playerUUID) { - return CompletableFuture.supplyAsync(() -> get().getUsers().loadUncachedUser(playerUUID), discordSRV.scheduler().executor()); + return discordSRV.scheduler().supply(() -> get().getUsers().loadUncachedUser(playerUUID)); } @Override @@ -114,7 +144,7 @@ public class EssentialsXIntegration )); } - @Subscribe + @Subscribe(priority = EventPriority.LAST) public void onGameChannelLookup(GameChannelLookupEvent event) { if (checkProcessor(event) || !discordSRV.server().getPluginManager().isPluginEnabled("EssentialsChat")) { return; diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/integration/PlaceholderAPIIntegration.java b/bukkit/src/main/java/com/discordsrv/bukkit/integration/PlaceholderAPIIntegration.java index e77d876a..fa4adbbd 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/integration/PlaceholderAPIIntegration.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/integration/PlaceholderAPIIntegration.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/integration/VaultIntegration.java b/bukkit/src/main/java/com/discordsrv/bukkit/integration/VaultIntegration.java index e0b63a49..8faae50d 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/integration/VaultIntegration.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/integration/VaultIntegration.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -116,20 +116,11 @@ public class VaultIntegration extends PluginIntegration implem } private CompletableFuture supply(CheckedSupplier supplier, boolean async) { - CompletableFuture future = new CompletableFuture<>(); - Runnable runnable = () -> { - try { - future.complete(supplier.get()); - } catch (Throwable e) { - future.completeExceptionally(e); - } - }; if (async) { - discordSRV.scheduler().run(runnable); + return discordSRV.scheduler().supply(supplier); } else { - discordSRV.scheduler().runOnMainThread(runnable); + return discordSRV.scheduler().supplyOnMainThread(supplier); } - return future; } private OfflinePlayer offlinePlayer(UUID player) { diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/ChattyChatIntegration.java b/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/ChattyChatIntegration.java index bcf29f96..531401d4 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/ChattyChatIntegration.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/ChattyChatIntegration.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/GriefPreventionChatIntegration.java b/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/GriefPreventionChatIntegration.java index 92a8ef15..e3fba0a6 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/GriefPreventionChatIntegration.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/GriefPreventionChatIntegration.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.bukkit.integration.chat; import com.discordsrv.api.event.bus.EventPriority; diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/LunaChatIntegration.java b/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/LunaChatIntegration.java index 0ab77393..c949ddb8 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/LunaChatIntegration.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/LunaChatIntegration.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/McMMOChatIntegration.java b/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/McMMOChatIntegration.java index 3206c482..c848332e 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/McMMOChatIntegration.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/McMMOChatIntegration.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.bukkit.integration.chat; import com.discordsrv.api.channel.GameChannel; diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/TownyChatIntegration.java b/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/TownyChatIntegration.java index 5700b6ba..542c0143 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/TownyChatIntegration.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/TownyChatIntegration.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/VentureChatIntegration.java b/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/VentureChatIntegration.java index dde33d09..4fbea4a7 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/VentureChatIntegration.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/VentureChatIntegration.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitConnectionListener.java b/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitConnectionListener.java index 9e18f262..0c0f2330 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitConnectionListener.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitConnectionListener.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitDeathListener.java b/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitDeathListener.java index f6a0ef52..14389c37 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitDeathListener.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitDeathListener.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitRequiredLinkingListener.java b/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitRequiredLinkingListener.java index 95b18379..16c0d336 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitRequiredLinkingListener.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitRequiredLinkingListener.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitStatusMessageListener.java b/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitStatusMessageListener.java index ccbb7dbf..e10ca33d 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitStatusMessageListener.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitStatusMessageListener.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/listener/award/BukkitAchievementListener.java b/bukkit/src/main/java/com/discordsrv/bukkit/listener/award/BukkitAchievementListener.java index 32656d3b..fd61a4ef 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/listener/award/BukkitAchievementListener.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/listener/award/BukkitAchievementListener.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/listener/award/BukkitAwardForwarder.java b/bukkit/src/main/java/com/discordsrv/bukkit/listener/award/BukkitAwardForwarder.java index 0a763803..8dd378f7 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/listener/award/BukkitAwardForwarder.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/listener/award/BukkitAwardForwarder.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/listener/chat/BukkitChatForwarder.java b/bukkit/src/main/java/com/discordsrv/bukkit/listener/chat/BukkitChatForwarder.java index 9083b4b9..fbb6d46c 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/listener/chat/BukkitChatForwarder.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/listener/chat/BukkitChatForwarder.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/listener/chat/BukkitChatListener.java b/bukkit/src/main/java/com/discordsrv/bukkit/listener/chat/BukkitChatListener.java index e4b4313f..b164781f 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/listener/chat/BukkitChatListener.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/listener/chat/BukkitChatListener.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitOfflinePlayer.java b/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitOfflinePlayer.java index bb7c24c4..11ab9390 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitOfflinePlayer.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitOfflinePlayer.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitPlayer.java b/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitPlayer.java index 2e013e57..f8cb24ef 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitPlayer.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitPlayer.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitPlayerProvider.java b/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitPlayerProvider.java index 82bbe6af..1c6f2ad6 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitPlayerProvider.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/player/BukkitPlayerProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -77,14 +77,14 @@ public class BukkitPlayerProvider extends ServerPlayerProvider getFuture(Supplier provider) { - return CompletableFuture.supplyAsync(() -> { + return discordSRV.scheduler().supply(() -> { OfflinePlayer offlinePlayer = provider.get(); if (offlinePlayer == null) { return null; } return new BukkitOfflinePlayer(discordSRV, offlinePlayer); - }, discordSRV.scheduler().executor()); + }); } @Override diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/plugin/BukkitPluginManager.java b/bukkit/src/main/java/com/discordsrv/bukkit/plugin/BukkitPluginManager.java index 8c6bd4de..8fde0dc2 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/plugin/BukkitPluginManager.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/plugin/BukkitPluginManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/requiredlinking/BukkitRequiredLinkingModule.java b/bukkit/src/main/java/com/discordsrv/bukkit/requiredlinking/BukkitRequiredLinkingModule.java index f03d0bcb..f601c8b9 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/requiredlinking/BukkitRequiredLinkingModule.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/requiredlinking/BukkitRequiredLinkingModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/AbstractBukkitScheduler.java b/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/AbstractBukkitScheduler.java index cce64723..edf6c8d7 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/AbstractBukkitScheduler.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/AbstractBukkitScheduler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/BukkitScheduler.java b/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/BukkitScheduler.java index f543a1b2..921a8dc3 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/BukkitScheduler.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/BukkitScheduler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -19,6 +19,7 @@ package com.discordsrv.bukkit.scheduler; import com.discordsrv.bukkit.BukkitDiscordSRV; +import org.jetbrains.annotations.NotNull; public class BukkitScheduler extends AbstractBukkitScheduler { @@ -27,17 +28,17 @@ public class BukkitScheduler extends AbstractBukkitScheduler { } @Override - public void runOnMainThread(Runnable task) { + public void runOnMainThread(@NotNull Runnable task) { checkDisable(task, (server, plugin) -> server.getScheduler().runTask(plugin, task)); } @Override - public void runOnMainThreadLaterInTicks(Runnable task, int ticks) { + public void runOnMainThreadLaterInTicks(@NotNull Runnable task, int ticks) { checkDisable(task, (server, plugin) -> server.getScheduler().runTaskLater(plugin, task, ticks)); } @Override - public void runOnMainThreadAtFixedRateInTicks(Runnable task, int initialTicks, int rateTicks) { + public void runOnMainThreadAtFixedRateInTicks(@NotNull Runnable task, int initialTicks, int rateTicks) { checkDisable(task, (server, plugin) -> server.getScheduler().runTaskTimer(plugin, task, initialTicks, rateTicks)); } } diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/FoliaScheduler.java b/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/FoliaScheduler.java index 550b65f4..95ab8cd8 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/FoliaScheduler.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/scheduler/FoliaScheduler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -19,6 +19,7 @@ package com.discordsrv.bukkit.scheduler; import com.discordsrv.bukkit.BukkitDiscordSRV; +import org.jetbrains.annotations.NotNull; public class FoliaScheduler extends AbstractBukkitScheduler implements IFoliaScheduler { @@ -27,17 +28,17 @@ public class FoliaScheduler extends AbstractBukkitScheduler implements IFoliaSch } @Override - public void runOnMainThread(Runnable task) { + public void runOnMainThread(@NotNull Runnable task) { checkDisable(task, (server, plugin) -> IFoliaScheduler.super.runOnMainThread(task)); } @Override - public void runOnMainThreadLaterInTicks(Runnable task, int ticks) { + public void runOnMainThreadLaterInTicks(@NotNull Runnable task, int ticks) { checkDisable(task, (server, plugin) -> IFoliaScheduler.super.runOnMainThreadLaterInTicks(task, ticks)); } @Override - public void runOnMainThreadAtFixedRateInTicks(Runnable task, int initialTicks, int rateTicks) { + public void runOnMainThreadAtFixedRateInTicks(@NotNull Runnable task, int initialTicks, int rateTicks) { checkDisable(task, (server, plugin) -> IFoliaScheduler.super.runOnMainThreadAtFixedRateInTicks(task, initialTicks, rateTicks)); } } diff --git a/bungee/loader/src/main/java/com/discordsrv/bungee/loader/DiscordSRVBungeeLoader.java b/bungee/loader/src/main/java/com/discordsrv/bungee/loader/DiscordSRVBungeeLoader.java index c784ec26..c532f594 100644 --- a/bungee/loader/src/main/java/com/discordsrv/bungee/loader/DiscordSRVBungeeLoader.java +++ b/bungee/loader/src/main/java/com/discordsrv/bungee/loader/DiscordSRVBungeeLoader.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java b/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java index 7e016c46..4fb9aeb0 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java +++ b/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bungee/src/main/java/com/discordsrv/bungee/DiscordSRVBungeeBootstrap.java b/bungee/src/main/java/com/discordsrv/bungee/DiscordSRVBungeeBootstrap.java index 3f73a5bc..6e4b1b97 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/DiscordSRVBungeeBootstrap.java +++ b/bungee/src/main/java/com/discordsrv/bungee/DiscordSRVBungeeBootstrap.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bungee/src/main/java/com/discordsrv/bungee/command/game/handler/BungeeCommandHandler.java b/bungee/src/main/java/com/discordsrv/bungee/command/game/handler/BungeeCommandHandler.java index 1298319c..cee3e735 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/command/game/handler/BungeeCommandHandler.java +++ b/bungee/src/main/java/com/discordsrv/bungee/command/game/handler/BungeeCommandHandler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bungee/src/main/java/com/discordsrv/bungee/command/game/sender/BungeeCommandSender.java b/bungee/src/main/java/com/discordsrv/bungee/command/game/sender/BungeeCommandSender.java index 7fd06a75..812b3e94 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/command/game/sender/BungeeCommandSender.java +++ b/bungee/src/main/java/com/discordsrv/bungee/command/game/sender/BungeeCommandSender.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bungee/src/main/java/com/discordsrv/bungee/component/package-info.java b/bungee/src/main/java/com/discordsrv/bungee/component/package-info.java index a79b29aa..c52b5a97 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/component/package-info.java +++ b/bungee/src/main/java/com/discordsrv/bungee/component/package-info.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bungee/src/main/java/com/discordsrv/bungee/component/util/BungeeComponentUtil.java b/bungee/src/main/java/com/discordsrv/bungee/component/util/BungeeComponentUtil.java index 1eb3dc84..a8f4477c 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/component/util/BungeeComponentUtil.java +++ b/bungee/src/main/java/com/discordsrv/bungee/component/util/BungeeComponentUtil.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bungee/src/main/java/com/discordsrv/bungee/console/BungeeConsole.java b/bungee/src/main/java/com/discordsrv/bungee/console/BungeeConsole.java index 59e9b749..7dfb496b 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/console/BungeeConsole.java +++ b/bungee/src/main/java/com/discordsrv/bungee/console/BungeeConsole.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bungee/src/main/java/com/discordsrv/bungee/console/executor/BungeeCommandExecutor.java b/bungee/src/main/java/com/discordsrv/bungee/console/executor/BungeeCommandExecutor.java index 4c2342f7..48bd7e99 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/console/executor/BungeeCommandExecutor.java +++ b/bungee/src/main/java/com/discordsrv/bungee/console/executor/BungeeCommandExecutor.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bungee/src/main/java/com/discordsrv/bungee/console/executor/BungeeCommandExecutorProvider.java b/bungee/src/main/java/com/discordsrv/bungee/console/executor/BungeeCommandExecutorProvider.java index e8be4d58..694c0774 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/console/executor/BungeeCommandExecutorProvider.java +++ b/bungee/src/main/java/com/discordsrv/bungee/console/executor/BungeeCommandExecutorProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bungee/src/main/java/com/discordsrv/bungee/console/executor/BungeeCommandExecutorProxyTemplate.java b/bungee/src/main/java/com/discordsrv/bungee/console/executor/BungeeCommandExecutorProxyTemplate.java index 36221f3d..76b68872 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/console/executor/BungeeCommandExecutorProxyTemplate.java +++ b/bungee/src/main/java/com/discordsrv/bungee/console/executor/BungeeCommandExecutorProxyTemplate.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bungee/src/main/java/com/discordsrv/bungee/player/BungeePlayer.java b/bungee/src/main/java/com/discordsrv/bungee/player/BungeePlayer.java index 5e5b7f5e..76c1d8db 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/player/BungeePlayer.java +++ b/bungee/src/main/java/com/discordsrv/bungee/player/BungeePlayer.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bungee/src/main/java/com/discordsrv/bungee/player/BungeePlayerProvider.java b/bungee/src/main/java/com/discordsrv/bungee/player/BungeePlayerProvider.java index eed25ad5..f3c3c62a 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/player/BungeePlayerProvider.java +++ b/bungee/src/main/java/com/discordsrv/bungee/player/BungeePlayerProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/bungee/src/main/java/com/discordsrv/bungee/plugin/BungeePluginManager.java b/bungee/src/main/java/com/discordsrv/bungee/plugin/BungeePluginManager.java index 5c8205f8..a6541a13 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/plugin/BungeePluginManager.java +++ b/bungee/src/main/java/com/discordsrv/bungee/plugin/BungeePluginManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/api/src/main/java/com/discordsrv/common/logging/LogAppender.java b/common/api/src/main/java/com/discordsrv/common/logging/LogAppender.java index 4c9cde6e..e23cb3a0 100644 --- a/common/api/src/main/java/com/discordsrv/common/logging/LogAppender.java +++ b/common/api/src/main/java/com/discordsrv/common/logging/LogAppender.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/api/src/main/java/com/discordsrv/common/logging/LogLevel.java b/common/api/src/main/java/com/discordsrv/common/logging/LogLevel.java index e5e6af21..4317aed8 100644 --- a/common/api/src/main/java/com/discordsrv/common/logging/LogLevel.java +++ b/common/api/src/main/java/com/discordsrv/common/logging/LogLevel.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/api/src/main/java/com/discordsrv/common/logging/adapter/DependencyLoggerAdapter.java b/common/api/src/main/java/com/discordsrv/common/logging/adapter/DependencyLoggerAdapter.java index d2999ae9..7018f031 100644 --- a/common/api/src/main/java/com/discordsrv/common/logging/adapter/DependencyLoggerAdapter.java +++ b/common/api/src/main/java/com/discordsrv/common/logging/adapter/DependencyLoggerAdapter.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/api/src/main/java/org/slf4j/impl/DiscordSRVLoggerFactory.java b/common/api/src/main/java/org/slf4j/impl/DiscordSRVLoggerFactory.java index 8d28042f..1fcb7221 100644 --- a/common/api/src/main/java/org/slf4j/impl/DiscordSRVLoggerFactory.java +++ b/common/api/src/main/java/org/slf4j/impl/DiscordSRVLoggerFactory.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/api/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/common/api/src/main/java/org/slf4j/impl/StaticLoggerBinder.java index b476f2a7..494df375 100644 --- a/common/api/src/main/java/org/slf4j/impl/StaticLoggerBinder.java +++ b/common/api/src/main/java/org/slf4j/impl/StaticLoggerBinder.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/api/src/main/java/org/slf4j/impl/StaticMDCBinder.java b/common/api/src/main/java/org/slf4j/impl/StaticMDCBinder.java index d2e4a781..f03dd892 100644 --- a/common/api/src/main/java/org/slf4j/impl/StaticMDCBinder.java +++ b/common/api/src/main/java/org/slf4j/impl/StaticMDCBinder.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/api/src/main/java/org/slf4j/impl/StaticMarkerBinder.java b/common/api/src/main/java/org/slf4j/impl/StaticMarkerBinder.java index 788aa457..2c750d60 100644 --- a/common/api/src/main/java/org/slf4j/impl/StaticMarkerBinder.java +++ b/common/api/src/main/java/org/slf4j/impl/StaticMarkerBinder.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/api/src/main/java/org/slf4j/impl/package-info.java b/common/api/src/main/java/org/slf4j/impl/package-info.java index aacac8e6..188b0a9c 100644 --- a/common/api/src/main/java/org/slf4j/impl/package-info.java +++ b/common/api/src/main/java/org/slf4j/impl/package-info.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java b/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java index 086b4771..4c47d576 100644 --- a/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java +++ b/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -46,6 +46,7 @@ import com.discordsrv.common.config.messages.MessagesConfig; import com.discordsrv.common.console.ConsoleModule; import com.discordsrv.common.debug.data.VersionInfo; import com.discordsrv.common.dependency.DiscordSRVDependencyManager; +import com.discordsrv.common.destination.DestinationLookupHelper; import com.discordsrv.common.discord.api.DiscordAPIEventModule; import com.discordsrv.common.discord.api.DiscordAPIImpl; import com.discordsrv.common.discord.connection.details.DiscordConnectionDetailsImpl; @@ -147,6 +148,7 @@ public abstract class AbstractDiscordSRV< private ModuleManager moduleManager; private JDAConnectionManager discordConnectionManager; private ChannelConfigHelper channelConfig; + private DestinationLookupHelper destinationLookupHelper; private Storage storage; private LinkProvider linkProvider; @@ -183,6 +185,7 @@ public abstract class AbstractDiscordSRV< this.discordConnectionDetails = new DiscordConnectionDetailsImpl(this); this.discordConnectionManager = new JDAConnectionManager(this); this.channelConfig = new ChannelConfigHelper(this); + this.destinationLookupHelper = new DestinationLookupHelper(this); this.updateChecker = new UpdateChecker(this); readManifest(); @@ -370,6 +373,11 @@ public abstract class AbstractDiscordSRV< return channelConfig; } + @Override + public DestinationLookupHelper destinations() { + return destinationLookupHelper; + } + @Override public final JDAConnectionManager discordConnectionManager() { return discordConnectionManager; @@ -531,7 +539,7 @@ public abstract class AbstractDiscordSRV< @Override public final CompletableFuture invokeDisable() { - return CompletableFuture.runAsync(this::disable, scheduler().executorService()); + return scheduler().execute(this::disable); } @Override @@ -693,7 +701,7 @@ public abstract class AbstractDiscordSRV< + "but linked-accounts.provider is set to \"minecraftauth\". Linked accounts will be disabled"); break; } - dependencyManager.mcAuthLib().download().get(); + dependencyManager.mcAuthLib().downloadRelocateAndLoad().get(); linkProvider = new MinecraftAuthenticationLinker(this); logger().info("Using minecraftauth.me for linked accounts"); break; @@ -727,7 +735,7 @@ public abstract class AbstractDiscordSRV< logger().warning("Data will not persist across server restarts."); } if (storageType.hikari()) { - dependencyManager().hikari().download().get(); + dependencyManager().hikari().downloadRelocateAndLoad().get(); } storage = storageType.storageFunction().apply(this); storage.initialize(); diff --git a/common/src/main/java/com/discordsrv/common/DiscordSRV.java b/common/src/main/java/com/discordsrv/common/DiscordSRV.java index 7e7d3a76..8c013882 100644 --- a/common/src/main/java/com/discordsrv/common/DiscordSRV.java +++ b/common/src/main/java/com/discordsrv/common/DiscordSRV.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -37,6 +37,7 @@ import com.discordsrv.common.console.Console; import com.discordsrv.common.debug.data.OnlineMode; import com.discordsrv.common.debug.data.VersionInfo; import com.discordsrv.common.dependency.DiscordSRVDependencyManager; +import com.discordsrv.common.destination.DestinationLookupHelper; import com.discordsrv.common.discord.api.DiscordAPIImpl; import com.discordsrv.common.discord.connection.details.DiscordConnectionDetailsImpl; import com.discordsrv.common.discord.connection.jda.JDAConnectionManager; @@ -135,6 +136,7 @@ public interface DiscordSRV extends DiscordSRVApi { // Config helper ChannelConfigHelper channelConfig(); + DestinationLookupHelper destinations(); // Internal JDAConnectionManager discordConnectionManager(); diff --git a/common/src/main/java/com/discordsrv/common/ProxyDiscordSRV.java b/common/src/main/java/com/discordsrv/common/ProxyDiscordSRV.java index 5951edd4..ff47b766 100644 --- a/common/src/main/java/com/discordsrv/common/ProxyDiscordSRV.java +++ b/common/src/main/java/com/discordsrv/common/ProxyDiscordSRV.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/ServerDiscordSRV.java b/common/src/main/java/com/discordsrv/common/ServerDiscordSRV.java index c58c664a..1c4d367c 100644 --- a/common/src/main/java/com/discordsrv/common/ServerDiscordSRV.java +++ b/common/src/main/java/com/discordsrv/common/ServerDiscordSRV.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -59,7 +59,7 @@ public abstract class ServerDiscordSRV< } public final CompletableFuture invokeServerStarted() { - return CompletableFuture.supplyAsync(() -> { + return scheduler().supply(() -> { if (status().isShutdown()) { // Already shutdown/shutting down, don't bother return null; @@ -76,7 +76,7 @@ public abstract class ServerDiscordSRV< logger().error("Failed to start", t); } return null; - }, scheduler().executorService()); + }); } @OverridingMethodsMustInvokeSuper diff --git a/common/src/main/java/com/discordsrv/common/api/util/ApiInstanceUtil.java b/common/src/main/java/com/discordsrv/common/api/util/ApiInstanceUtil.java index 28ea9a59..bed3e012 100644 --- a/common/src/main/java/com/discordsrv/common/api/util/ApiInstanceUtil.java +++ b/common/src/main/java/com/discordsrv/common/api/util/ApiInstanceUtil.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/bootstrap/IBootstrap.java b/common/src/main/java/com/discordsrv/common/bootstrap/IBootstrap.java index f0544746..5603fc62 100644 --- a/common/src/main/java/com/discordsrv/common/bootstrap/IBootstrap.java +++ b/common/src/main/java/com/discordsrv/common/bootstrap/IBootstrap.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/bootstrap/LifecycleManager.java b/common/src/main/java/com/discordsrv/common/bootstrap/LifecycleManager.java index 74e70b26..b7fc3ae6 100644 --- a/common/src/main/java/com/discordsrv/common/bootstrap/LifecycleManager.java +++ b/common/src/main/java/com/discordsrv/common/bootstrap/LifecycleManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -63,33 +63,29 @@ public class LifecycleManager { classpathAppender, resourcePaths.toArray(new String[0]) ); - this.completableFuture = dependencyLoader.download(); - completableFuture.whenComplete((v, t) -> taskPool.shutdown()); + this.completableFuture.whenComplete((v, t) -> taskPool.shutdownNow()); } public void loadAndEnable(Supplier discordSRVSupplier) { - if (load()) { - enable(discordSRVSupplier); + if (relocateAndLoad()) { + discordSRVSupplier.get().runEnable(); } } - private boolean load() { + private boolean relocateAndLoad() { try { completableFuture.get(); + dependencyLoader.relocateAndLoad(false).get(); return true; } catch (InterruptedException ignored) { Thread.currentThread().interrupt(); } catch (ExecutionException e) { - logger.error("Failed to download dependencies", e.getCause()); + logger.error("Failed to download, relocate or load dependencies", e.getCause()); } return false; } - private void enable(Supplier discordSRVSupplier) { - discordSRVSupplier.get().runEnable(); - } - public void reload(DiscordSRV discordSRV) { if (discordSRV == null) { return; diff --git a/common/src/main/java/com/discordsrv/common/channel/ChannelConfigHelper.java b/common/src/main/java/com/discordsrv/common/channel/ChannelConfigHelper.java index a47fe86e..80d790ea 100644 --- a/common/src/main/java/com/discordsrv/common/channel/ChannelConfigHelper.java +++ b/common/src/main/java/com/discordsrv/common/channel/ChannelConfigHelper.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -33,8 +33,8 @@ import com.discordsrv.common.config.main.generic.ThreadConfig; import com.github.benmanes.caffeine.cache.CacheLoader; import com.github.benmanes.caffeine.cache.LoadingCache; import org.apache.commons.lang3.tuple.Pair; -import org.checkerframework.checker.nullness.qual.NonNull; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.spongepowered.configurate.CommentedConfigurationNode; import org.spongepowered.configurate.objectmapping.ObjectMapper; import org.spongepowered.configurate.serialize.SerializationException; @@ -65,7 +65,7 @@ public class ChannelConfigHelper { .build(new CacheLoader() { @Override - public @Nullable GameChannel load(@NonNull String channelName) { + public @Nullable GameChannel load(@NotNull String channelName) { GameChannelLookupEvent event = new GameChannelLookupEvent(null, channelName); discordSRV.eventBus().publish(event); if (!event.isProcessed()) { @@ -199,11 +199,13 @@ public class ChannelConfigHelper { return channelConfigs; } - public BaseChannelConfig get(GameChannel gameChannel) { + @Nullable + public BaseChannelConfig get(@NotNull GameChannel gameChannel) { return resolve(gameChannel.getOwnerName(), gameChannel.getChannelName()); } - public BaseChannelConfig resolve(String ownerName, String channelName) { + @Nullable + public BaseChannelConfig resolve(@Nullable String ownerName, @NotNull String channelName) { if (ownerName != null) { ownerName = ownerName.toLowerCase(Locale.ROOT); diff --git a/common/src/main/java/com/discordsrv/common/channel/ChannelLockingModule.java b/common/src/main/java/com/discordsrv/common/channel/ChannelLockingModule.java index ffe93215..3729794f 100644 --- a/common/src/main/java/com/discordsrv/common/channel/ChannelLockingModule.java +++ b/common/src/main/java/com/discordsrv/common/channel/ChannelLockingModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -24,6 +24,7 @@ import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.config.main.channels.ChannelLockingConfig; import com.discordsrv.common.config.main.channels.base.BaseChannelConfig; import com.discordsrv.common.config.main.channels.base.IChannelConfig; +import com.discordsrv.common.discord.util.DiscordPermissionUtil; import com.discordsrv.common.module.type.AbstractModule; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.Guild; @@ -31,12 +32,11 @@ import net.dv8tion.jda.api.entities.IPermissionHolder; import net.dv8tion.jda.api.entities.Role; import net.dv8tion.jda.api.entities.channel.attribute.IPermissionContainer; import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel; +import net.dv8tion.jda.api.managers.channel.concrete.ThreadChannelManager; import net.dv8tion.jda.api.requests.restaction.PermissionOverrideAction; import java.util.ArrayList; -import java.util.Collection; import java.util.List; -import java.util.function.BiConsumer; public class ChannelLockingModule extends AbstractModule { @@ -51,55 +51,48 @@ public class ChannelLockingModule extends AbstractModule { @Override public void enable() { - doForAllChannels((config, channelConfig) -> { - ChannelLockingConfig shutdownConfig = config.channelLocking; - ChannelLockingConfig.Channels channels = shutdownConfig.channels; - ChannelLockingConfig.Threads threads = shutdownConfig.threads; - - discordSRV.discordAPI() - .findOrCreateDestinations((BaseChannelConfig & IChannelConfig) config, threads.unarchive, true) - .whenComplete((destinations, t) -> { - if (channels.everyone || !channels.roleIds.isEmpty()) { - for (DiscordGuildMessageChannel destination : destinations) { - channelPermissions(channels, destination, true); - } - } - }); - }); + run(true); } @Override public void disable() { - doForAllChannels((config, channelConfig) -> { - if (!(config instanceof IChannelConfig)) { - return; + run(false); + } + + private void run(boolean unlocked) { + for (BaseChannelConfig config : discordSRV.channelConfig().getAllChannels()) { + IChannelConfig channelConfig = config instanceof IChannelConfig ? (IChannelConfig) config : null; + if (channelConfig == null) { + continue; } - ChannelLockingConfig shutdownConfig = config.channelLocking; - ChannelLockingConfig.Channels channels = shutdownConfig.channels; - ChannelLockingConfig.Threads threads = shutdownConfig.threads; + ChannelLockingConfig lockingConfig = config.channelLocking; + ChannelLockingConfig.Channels channels = lockingConfig.channels; + ChannelLockingConfig.Threads threads = lockingConfig.threads; - boolean archive = threads.archive; boolean isChannels = channels.everyone || !channels.roleIds.isEmpty(); - if (!threads.archive && !isChannels) { - return; - } + boolean isThreads = threads.archive || threads.lock; - Collection destinations = discordSRV.discordAPI() - .findDestinations((BaseChannelConfig & IChannelConfig) config, true); - - for (DiscordGuildMessageChannel destination : destinations) { - if (archive && destination instanceof DiscordThreadChannel) { - ((DiscordThreadChannel) destination).asJDA().getManager() - .setArchived(true) - .reason("DiscordSRV channel locking") - .queue(); - } - if (isChannels) { - channelPermissions(channels, destination, false); - } - } - }); + discordSRV.destinations() + .lookupDestination(channelConfig.destination(), false, true) + .whenComplete((destinations, t) -> { + for (DiscordGuildMessageChannel destination : destinations) { + if (isThreads && destination instanceof DiscordThreadChannel) { + ThreadChannelManager manager = ((DiscordThreadChannel) destination).asJDA().getManager(); + if (threads.archive) { + manager = manager.setArchived(!unlocked); + } + if (threads.lock) { + manager = manager.setLocked(!unlocked); + } + manager.reason("DiscordSRV channel locking").queue(); + } + if (isChannels) { + channelPermissions(channels, destination, unlocked); + } + } + }); + } } private void channelPermissions( @@ -130,8 +123,9 @@ public class ChannelLockingModule extends AbstractModule { } Guild guild = messageChannel.getGuild(); - if (!guild.getSelfMember().hasPermission(messageChannel, Permission.MANAGE_PERMISSIONS)) { - logger().error("Cannot change permissions of " + channel + ": lacking \"Manage Permissions\" permission"); + String missingPermissions = DiscordPermissionUtil.missingPermissionsString(messageChannel, Permission.VIEW_CHANNEL, Permission.MANAGE_PERMISSIONS); + if (missingPermissions != null) { + logger().error("Cannot lock #" + channel.getName() + ": " + missingPermissions); return; } @@ -162,15 +156,4 @@ public class ChannelLockingModule extends AbstractModule { } action.reason("DiscordSRV channel locking").queue(); } - - private void doForAllChannels(BiConsumer channelConsumer) { - for (BaseChannelConfig config : discordSRV.channelConfig().getAllChannels()) { - IChannelConfig channelConfig = config instanceof IChannelConfig ? (IChannelConfig) config : null; - if (channelConfig == null) { - continue; - } - - channelConsumer.accept(config, channelConfig); - } - } } diff --git a/common/src/main/java/com/discordsrv/common/channel/GlobalChannel.java b/common/src/main/java/com/discordsrv/common/channel/GlobalChannel.java index 1c78055f..a4d4befb 100644 --- a/common/src/main/java/com/discordsrv/common/channel/GlobalChannel.java +++ b/common/src/main/java/com/discordsrv/common/channel/GlobalChannel.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/channel/GlobalChannelLookupModule.java b/common/src/main/java/com/discordsrv/common/channel/GlobalChannelLookupModule.java index 44c06e99..3380bb65 100644 --- a/common/src/main/java/com/discordsrv/common/channel/GlobalChannelLookupModule.java +++ b/common/src/main/java/com/discordsrv/common/channel/GlobalChannelLookupModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/channel/TimedUpdaterModule.java b/common/src/main/java/com/discordsrv/common/channel/TimedUpdaterModule.java index 0d4f7fb3..8049edea 100644 --- a/common/src/main/java/com/discordsrv/common/channel/TimedUpdaterModule.java +++ b/common/src/main/java/com/discordsrv/common/channel/TimedUpdaterModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/combined/abstraction/CombinedCommand.java b/common/src/main/java/com/discordsrv/common/command/combined/abstraction/CombinedCommand.java index ef8abaa3..905af966 100644 --- a/common/src/main/java/com/discordsrv/common/command/combined/abstraction/CombinedCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/combined/abstraction/CombinedCommand.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.combined.abstraction; import com.discordsrv.api.discord.entity.interaction.command.DiscordCommand; diff --git a/common/src/main/java/com/discordsrv/common/command/combined/abstraction/CommandExecution.java b/common/src/main/java/com/discordsrv/common/command/combined/abstraction/CommandExecution.java index e9d81df1..1855386c 100644 --- a/common/src/main/java/com/discordsrv/common/command/combined/abstraction/CommandExecution.java +++ b/common/src/main/java/com/discordsrv/common/command/combined/abstraction/CommandExecution.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.combined.abstraction; import com.discordsrv.api.component.MinecraftComponent; diff --git a/common/src/main/java/com/discordsrv/common/command/combined/abstraction/DiscordCommandExecution.java b/common/src/main/java/com/discordsrv/common/command/combined/abstraction/DiscordCommandExecution.java index cbeb75fa..7ad66b87 100644 --- a/common/src/main/java/com/discordsrv/common/command/combined/abstraction/DiscordCommandExecution.java +++ b/common/src/main/java/com/discordsrv/common/command/combined/abstraction/DiscordCommandExecution.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.combined.abstraction; import com.discordsrv.api.event.events.discord.interaction.command.DiscordChatInputInteractionEvent; diff --git a/common/src/main/java/com/discordsrv/common/command/combined/abstraction/GameCommandExecution.java b/common/src/main/java/com/discordsrv/common/command/combined/abstraction/GameCommandExecution.java index 46fbc3cf..bd1ac3d1 100644 --- a/common/src/main/java/com/discordsrv/common/command/combined/abstraction/GameCommandExecution.java +++ b/common/src/main/java/com/discordsrv/common/command/combined/abstraction/GameCommandExecution.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.combined.abstraction; import com.discordsrv.common.DiscordSRV; diff --git a/common/src/main/java/com/discordsrv/common/command/combined/abstraction/Text.java b/common/src/main/java/com/discordsrv/common/command/combined/abstraction/Text.java index 1d80d23f..cb9232bf 100644 --- a/common/src/main/java/com/discordsrv/common/command/combined/abstraction/Text.java +++ b/common/src/main/java/com/discordsrv/common/command/combined/abstraction/Text.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.combined.abstraction; import net.kyori.adventure.text.format.TextColor; diff --git a/common/src/main/java/com/discordsrv/common/command/combined/commands/DebugCommand.java b/common/src/main/java/com/discordsrv/common/command/combined/commands/DebugCommand.java index 6965584e..abbbd239 100644 --- a/common/src/main/java/com/discordsrv/common/command/combined/commands/DebugCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/combined/commands/DebugCommand.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -86,7 +86,7 @@ public class DebugCommand extends CombinedCommand { } private static final String URL_FORMAT = DiscordSRV.WEBSITE + "/debug/%s#%s"; - private static final Base64.Encoder KEY_ENCODER = Base64.getUrlEncoder().withoutPadding(); + public static final Base64.Encoder KEY_ENCODER = Base64.getUrlEncoder().withoutPadding(); private final PasteService pasteService; diff --git a/common/src/main/java/com/discordsrv/common/command/combined/commands/LinkInitCommand.java b/common/src/main/java/com/discordsrv/common/command/combined/commands/LinkInitCommand.java index bd0e97ba..66a533ac 100644 --- a/common/src/main/java/com/discordsrv/common/command/combined/commands/LinkInitCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/combined/commands/LinkInitCommand.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.combined.commands; import com.discordsrv.api.discord.entity.interaction.command.CommandOption; diff --git a/common/src/main/java/com/discordsrv/common/command/combined/commands/LinkedCommand.java b/common/src/main/java/com/discordsrv/common/command/combined/commands/LinkedCommand.java index 95b464c7..a5906459 100644 --- a/common/src/main/java/com/discordsrv/common/command/combined/commands/LinkedCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/combined/commands/LinkedCommand.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.combined.commands; import com.discordsrv.api.discord.entity.interaction.command.CommandOption; diff --git a/common/src/main/java/com/discordsrv/common/command/combined/commands/ResyncCommand.java b/common/src/main/java/com/discordsrv/common/command/combined/commands/ResyncCommand.java index ea81a078..1c405322 100644 --- a/common/src/main/java/com/discordsrv/common/command/combined/commands/ResyncCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/combined/commands/ResyncCommand.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.combined.commands; import com.discordsrv.api.discord.entity.interaction.command.DiscordCommand; diff --git a/common/src/main/java/com/discordsrv/common/command/combined/commands/UnlinkCommand.java b/common/src/main/java/com/discordsrv/common/command/combined/commands/UnlinkCommand.java index 1a4b6a67..b1b4a5b1 100644 --- a/common/src/main/java/com/discordsrv/common/command/combined/commands/UnlinkCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/combined/commands/UnlinkCommand.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.combined.commands; import com.discordsrv.api.discord.entity.interaction.command.CommandOption; diff --git a/common/src/main/java/com/discordsrv/common/command/combined/commands/VersionCommand.java b/common/src/main/java/com/discordsrv/common/command/combined/commands/VersionCommand.java index cdbc9e3c..f21fc5e7 100644 --- a/common/src/main/java/com/discordsrv/common/command/combined/commands/VersionCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/combined/commands/VersionCommand.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/discord/DiscordCommandModule.java b/common/src/main/java/com/discordsrv/common/command/discord/DiscordCommandModule.java index a876cea6..fecf8b3f 100644 --- a/common/src/main/java/com/discordsrv/common/command/discord/DiscordCommandModule.java +++ b/common/src/main/java/com/discordsrv/common/command/discord/DiscordCommandModule.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.discord; import com.discordsrv.api.event.bus.Subscribe; diff --git a/common/src/main/java/com/discordsrv/common/command/discord/commands/DiscordSRVDiscordCommand.java b/common/src/main/java/com/discordsrv/common/command/discord/commands/DiscordSRVDiscordCommand.java index 25f73f3a..0e675973 100644 --- a/common/src/main/java/com/discordsrv/common/command/discord/commands/DiscordSRVDiscordCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/discord/commands/DiscordSRVDiscordCommand.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.discord.commands; import com.discordsrv.api.discord.entity.interaction.command.DiscordCommand; diff --git a/common/src/main/java/com/discordsrv/common/command/discord/commands/subcommand/ExecuteCommand.java b/common/src/main/java/com/discordsrv/common/command/discord/commands/subcommand/ExecuteCommand.java index 67d6edd0..4392f2f8 100644 --- a/common/src/main/java/com/discordsrv/common/command/discord/commands/subcommand/ExecuteCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/discord/commands/subcommand/ExecuteCommand.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.discord.commands.subcommand; import com.discordsrv.api.discord.entity.DiscordUser; diff --git a/common/src/main/java/com/discordsrv/common/command/game/GameCommandExecutionHelper.java b/common/src/main/java/com/discordsrv/common/command/game/GameCommandExecutionHelper.java index 7da552fa..f9739472 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/GameCommandExecutionHelper.java +++ b/common/src/main/java/com/discordsrv/common/command/game/GameCommandExecutionHelper.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.game; import java.util.List; diff --git a/common/src/main/java/com/discordsrv/common/command/game/GameCommandModule.java b/common/src/main/java/com/discordsrv/common/command/game/GameCommandModule.java index 79745800..f87f90bb 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/GameCommandModule.java +++ b/common/src/main/java/com/discordsrv/common/command/game/GameCommandModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommand.java b/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommand.java index cbabe8e0..d8c30e23 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommand.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommandArguments.java b/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommandArguments.java index bbeb40bf..317e997c 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommandArguments.java +++ b/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommandArguments.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommandExecutor.java b/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommandExecutor.java index f3ce90ea..52196ea8 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommandExecutor.java +++ b/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommandExecutor.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommandSuggester.java b/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommandSuggester.java index 318ae091..c8b46da1 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommandSuggester.java +++ b/common/src/main/java/com/discordsrv/common/command/game/abstraction/GameCommandSuggester.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/game/commands/DiscordSRVGameCommand.java b/common/src/main/java/com/discordsrv/common/command/game/commands/DiscordSRVGameCommand.java index 588b40e6..dba63bdf 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/commands/DiscordSRVGameCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/game/commands/DiscordSRVGameCommand.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/game/commands/subcommand/BroadcastCommand.java b/common/src/main/java/com/discordsrv/common/command/game/commands/subcommand/BroadcastCommand.java index ff982b5a..d70ab9e3 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/commands/subcommand/BroadcastCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/game/commands/subcommand/BroadcastCommand.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -103,7 +103,7 @@ public abstract class BroadcastCommand implements GameCommandExecutor, GameComma String content = arguments.getString("content"); Set channels = new HashSet<>(); - CompletableFuture> future = null; + CompletableFuture> future = null; try { long id = Long.parseUnsignedLong(channel); @@ -116,7 +116,7 @@ public abstract class BroadcastCommand implements GameCommandExecutor, GameComma CC config = channelConfig instanceof IChannelConfig ? (CC) channelConfig : null; if (config != null) { - future = discordSRV.discordAPI().findOrCreateDestinations(config, true, false); + future = discordSRV.destinations().lookupDestination(config.destination(), true, false); } } diff --git a/common/src/main/java/com/discordsrv/common/command/game/commands/subcommand/reload/ReloadCommand.java b/common/src/main/java/com/discordsrv/common/command/game/commands/subcommand/reload/ReloadCommand.java index ca8f54ae..eac76165 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/commands/subcommand/reload/ReloadCommand.java +++ b/common/src/main/java/com/discordsrv/common/command/game/commands/subcommand/reload/ReloadCommand.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/game/commands/subcommand/reload/ReloadResults.java b/common/src/main/java/com/discordsrv/common/command/game/commands/subcommand/reload/ReloadResults.java index 3b24e60b..4733773b 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/commands/subcommand/reload/ReloadResults.java +++ b/common/src/main/java/com/discordsrv/common/command/game/commands/subcommand/reload/ReloadResults.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.game.commands.subcommand.reload; import com.discordsrv.api.DiscordSRVApi; diff --git a/common/src/main/java/com/discordsrv/common/command/game/executor/AdventureCommandExecutorProxyTemplate.java b/common/src/main/java/com/discordsrv/common/command/game/executor/AdventureCommandExecutorProxyTemplate.java index ad097cf1..37bc90c9 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/executor/AdventureCommandExecutorProxyTemplate.java +++ b/common/src/main/java/com/discordsrv/common/command/game/executor/AdventureCommandExecutorProxyTemplate.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/game/executor/CommandExecutor.java b/common/src/main/java/com/discordsrv/common/command/game/executor/CommandExecutor.java index fb36ddc0..2c6fb678 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/executor/CommandExecutor.java +++ b/common/src/main/java/com/discordsrv/common/command/game/executor/CommandExecutor.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/game/executor/CommandExecutorProvider.java b/common/src/main/java/com/discordsrv/common/command/game/executor/CommandExecutorProvider.java index ea57253f..1eeb64c7 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/executor/CommandExecutorProvider.java +++ b/common/src/main/java/com/discordsrv/common/command/game/executor/CommandExecutorProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/game/handler/BasicCommandHandler.java b/common/src/main/java/com/discordsrv/common/command/game/handler/BasicCommandHandler.java index b2591c56..7075e823 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/handler/BasicCommandHandler.java +++ b/common/src/main/java/com/discordsrv/common/command/game/handler/BasicCommandHandler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/game/handler/ICommandHandler.java b/common/src/main/java/com/discordsrv/common/command/game/handler/ICommandHandler.java index 5b427d47..ea6f6aa8 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/handler/ICommandHandler.java +++ b/common/src/main/java/com/discordsrv/common/command/game/handler/ICommandHandler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/game/handler/util/BrigadierUtil.java b/common/src/main/java/com/discordsrv/common/command/game/handler/util/BrigadierUtil.java index a7bc6ce4..5b904423 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/handler/util/BrigadierUtil.java +++ b/common/src/main/java/com/discordsrv/common/command/game/handler/util/BrigadierUtil.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/game/sender/ICommandSender.java b/common/src/main/java/com/discordsrv/common/command/game/sender/ICommandSender.java index 08c958ef..64d8391f 100644 --- a/common/src/main/java/com/discordsrv/common/command/game/sender/ICommandSender.java +++ b/common/src/main/java/com/discordsrv/common/command/game/sender/ICommandSender.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/command/util/CommandUtil.java b/common/src/main/java/com/discordsrv/common/command/util/CommandUtil.java index 70d1bb86..b756b83f 100644 --- a/common/src/main/java/com/discordsrv/common/command/util/CommandUtil.java +++ b/common/src/main/java/com/discordsrv/common/command/util/CommandUtil.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.command.util; import com.discordsrv.common.DiscordSRV; diff --git a/common/src/main/java/com/discordsrv/common/component/ComponentFactory.java b/common/src/main/java/com/discordsrv/common/component/ComponentFactory.java index 7ad3735d..7d661fcf 100644 --- a/common/src/main/java/com/discordsrv/common/component/ComponentFactory.java +++ b/common/src/main/java/com/discordsrv/common/component/ComponentFactory.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -90,10 +90,10 @@ public class ComponentFactory implements MinecraftComponentFactory { } return translation.translate( - component.args() + component.arguments() .stream() - .map(discordSerializer::serialize) - .map(str -> (Object) str) + // Prevent infinite loop here by using the default PlainTextSerializer + .map(argument -> PlainTextComponentSerializer.plainText().serialize(argument.asComponent())) .toArray(Object[]::new) ); } diff --git a/common/src/main/java/com/discordsrv/common/component/EnhancedTextBuilderImpl.java b/common/src/main/java/com/discordsrv/common/component/EnhancedTextBuilderImpl.java index 1dcf6f74..dc69f4eb 100644 --- a/common/src/main/java/com/discordsrv/common/component/EnhancedTextBuilderImpl.java +++ b/common/src/main/java/com/discordsrv/common/component/EnhancedTextBuilderImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -30,7 +30,10 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextColor; import org.jetbrains.annotations.NotNull; -import java.util.*; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/common/src/main/java/com/discordsrv/common/component/MinecraftComponentImpl.java b/common/src/main/java/com/discordsrv/common/component/MinecraftComponentImpl.java index 9943a26e..b6b70b8c 100644 --- a/common/src/main/java/com/discordsrv/common/component/MinecraftComponentImpl.java +++ b/common/src/main/java/com/discordsrv/common/component/MinecraftComponentImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -40,7 +40,7 @@ public class MinecraftComponentImpl implements MinecraftComponent { setJson(json); } - public MinecraftComponentImpl(Component component) { + public MinecraftComponentImpl(@NotNull Component component) { setComponent(component); } @@ -48,7 +48,7 @@ public class MinecraftComponentImpl implements MinecraftComponent { return component; } - public void setComponent(Component component) { + public void setComponent(@NotNull Component component) { this.component = component; this.json = GsonComponentSerializer.gson().serialize(component); } diff --git a/common/src/main/java/com/discordsrv/common/component/renderer/DiscordSRVMinecraftRenderer.java b/common/src/main/java/com/discordsrv/common/component/renderer/DiscordSRVMinecraftRenderer.java index ecc3f18b..f66b3946 100644 --- a/common/src/main/java/com/discordsrv/common/component/renderer/DiscordSRVMinecraftRenderer.java +++ b/common/src/main/java/com/discordsrv/common/component/renderer/DiscordSRVMinecraftRenderer.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -18,7 +18,6 @@ package com.discordsrv.common.component.renderer; -import com.discordsrv.api.component.GameTextBuilder; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.guild.DiscordCustomEmoji; import com.discordsrv.api.discord.entity.guild.DiscordGuild; diff --git a/common/src/main/java/com/discordsrv/common/component/translation/StringFormatTranslation.java b/common/src/main/java/com/discordsrv/common/component/translation/StringFormatTranslation.java index 9a2fc0a9..13a12c4f 100644 --- a/common/src/main/java/com/discordsrv/common/component/translation/StringFormatTranslation.java +++ b/common/src/main/java/com/discordsrv/common/component/translation/StringFormatTranslation.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/component/translation/Translation.java b/common/src/main/java/com/discordsrv/common/component/translation/Translation.java index 5bf85dbf..f2de9373 100644 --- a/common/src/main/java/com/discordsrv/common/component/translation/Translation.java +++ b/common/src/main/java/com/discordsrv/common/component/translation/Translation.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/component/translation/TranslationRegistry.java b/common/src/main/java/com/discordsrv/common/component/translation/TranslationRegistry.java index e6dd63eb..b61d97fe 100644 --- a/common/src/main/java/com/discordsrv/common/component/translation/TranslationRegistry.java +++ b/common/src/main/java/com/discordsrv/common/component/translation/TranslationRegistry.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/component/util/ComponentUtil.java b/common/src/main/java/com/discordsrv/common/component/util/ComponentUtil.java index 2afcfb2f..6feedb68 100644 --- a/common/src/main/java/com/discordsrv/common/component/util/ComponentUtil.java +++ b/common/src/main/java/com/discordsrv/common/component/util/ComponentUtil.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -26,6 +26,9 @@ import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Collection; @@ -36,25 +39,34 @@ public final class ComponentUtil { private static MinecraftComponentAdapter ADAPTER; + @NotNull private static MinecraftComponentAdapter getAdapter() { return ADAPTER != null ? ADAPTER : (ADAPTER = MinecraftComponentAdapter.create(GsonComponentSerializer.class, Component.class)); } private ComponentUtil() {} - public static boolean isEmpty(Component component) { + public static boolean isEmpty(@NotNull Component component) { return PlainTextComponentSerializer.plainText().serialize(component).isEmpty(); } - public static boolean isEmpty(MinecraftComponent component) { + public static boolean isEmpty(@NotNull MinecraftComponent component) { return component.asPlainString().isEmpty(); } + @Contract("null -> null") public static MinecraftComponent toAPI(Component component) { + if (component == null) { + return null; + } return new MinecraftComponentImpl(component); } - public static Component fromAPI(MinecraftComponent component) { + @Contract("null -> null") + public static Component fromAPI(@Nullable MinecraftComponent component) { + if (component == null) { + return null; + } if (component instanceof MinecraftComponentImpl) { return ((MinecraftComponentImpl) component).getComponent(); } else { @@ -70,7 +82,7 @@ public final class ComponentUtil { } } - public static MinecraftComponent fromUnrelocated(Object unrelocatedAdventure) { + public static MinecraftComponent fromUnrelocated(@NotNull Object unrelocatedAdventure) { MinecraftComponentImpl component = MinecraftComponentImpl.empty(); MinecraftComponent.Adapter adapter = component.unrelocatedAdapter(); if (adapter == null) { @@ -80,11 +92,11 @@ public final class ComponentUtil { return component; } - public static Component join(Component delimiter, Collection components) { + public static Component join(@NotNull Component delimiter, @NotNull Collection components) { return join(delimiter, components.toArray(new ComponentLike[0])); } - public static Component join(Component delimiter, ComponentLike[] components) { + public static Component join(@NotNull Component delimiter, @NotNull ComponentLike[] components) { TextComponent.Builder builder = Component.text(); for (int i = 0; i < components.length; i++) { builder.append(components[i]); diff --git a/common/src/main/java/com/discordsrv/common/config/Config.java b/common/src/main/java/com/discordsrv/common/config/Config.java index a5e44cf8..701f4fd3 100644 --- a/common/src/main/java/com/discordsrv/common/config/Config.java +++ b/common/src/main/java/com/discordsrv/common/config/Config.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/annotation/Constants.java b/common/src/main/java/com/discordsrv/common/config/configurate/annotation/Constants.java index 64375794..a3208d9d 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/annotation/Constants.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/annotation/Constants.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.configurate.annotation; import java.lang.annotation.Retention; diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/annotation/DefaultOnly.java b/common/src/main/java/com/discordsrv/common/config/configurate/annotation/DefaultOnly.java index e6554f07..b500c44d 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/annotation/DefaultOnly.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/annotation/DefaultOnly.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/annotation/Order.java b/common/src/main/java/com/discordsrv/common/config/configurate/annotation/Order.java index 4d3a95a2..f772d550 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/annotation/Order.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/annotation/Order.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/annotation/Untranslated.java b/common/src/main/java/com/discordsrv/common/config/configurate/annotation/Untranslated.java index 194f3a76..a124c8bf 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/annotation/Untranslated.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/annotation/Untranslated.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/fielddiscoverer/OrderedFieldDiscovererProxy.java b/common/src/main/java/com/discordsrv/common/config/configurate/fielddiscoverer/OrderedFieldDiscovererProxy.java index edc9fc52..e565ac19 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/fielddiscoverer/OrderedFieldDiscovererProxy.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/fielddiscoverer/OrderedFieldDiscovererProxy.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/manager/ConnectionConfigManager.java b/common/src/main/java/com/discordsrv/common/config/configurate/manager/ConnectionConfigManager.java index 7d567e2b..c891c5dc 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/manager/ConnectionConfigManager.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/manager/ConnectionConfigManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/manager/MainConfigManager.java b/common/src/main/java/com/discordsrv/common/config/configurate/manager/MainConfigManager.java index 86923fd9..c35ea693 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/manager/MainConfigManager.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/manager/MainConfigManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/manager/MessagesConfigManager.java b/common/src/main/java/com/discordsrv/common/config/configurate/manager/MessagesConfigManager.java index ade13809..2ed72676 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/manager/MessagesConfigManager.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/manager/MessagesConfigManager.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.configurate.manager; import com.discordsrv.common.DiscordSRV; diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/manager/MessagesConfigSingleManager.java b/common/src/main/java/com/discordsrv/common/config/configurate/manager/MessagesConfigSingleManager.java index 76380133..ab750c9e 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/manager/MessagesConfigSingleManager.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/manager/MessagesConfigSingleManager.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.configurate.manager; import com.discordsrv.common.DiscordSRV; diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ConfigManager.java b/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ConfigManager.java index c69f83b1..1481dcb1 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ConfigManager.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ConfigManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ConfigurateConfigManager.java b/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ConfigurateConfigManager.java index 5204620b..07dad746 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ConfigurateConfigManager.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ConfigurateConfigManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ProxyConfigManager.java b/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ProxyConfigManager.java index 2f9a269e..f79586fb 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ProxyConfigManager.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ProxyConfigManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ServerConfigManager.java b/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ServerConfigManager.java index 97f3fa84..ee2a60f4 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ServerConfigManager.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/ServerConfigManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/TranslatedConfigManager.java b/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/TranslatedConfigManager.java index a505005a..f931a7ff 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/TranslatedConfigManager.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/manager/abstraction/TranslatedConfigManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/manager/loader/ConfigLoaderProvider.java b/common/src/main/java/com/discordsrv/common/config/configurate/manager/loader/ConfigLoaderProvider.java index 385545ad..10e76100 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/manager/loader/ConfigLoaderProvider.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/manager/loader/ConfigLoaderProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/manager/loader/YamlConfigLoaderProvider.java b/common/src/main/java/com/discordsrv/common/config/configurate/manager/loader/YamlConfigLoaderProvider.java index 7d67cc49..001af08f 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/manager/loader/YamlConfigLoaderProvider.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/manager/loader/YamlConfigLoaderProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/serializer/ColorSerializer.java b/common/src/main/java/com/discordsrv/common/config/configurate/serializer/ColorSerializer.java index 01725fa1..51317d35 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/serializer/ColorSerializer.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/serializer/ColorSerializer.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/serializer/DiscordMessageEmbedSerializer.java b/common/src/main/java/com/discordsrv/common/config/configurate/serializer/DiscordMessageEmbedSerializer.java index f5126731..580bf524 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/serializer/DiscordMessageEmbedSerializer.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/serializer/DiscordMessageEmbedSerializer.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/serializer/EnumSerializer.java b/common/src/main/java/com/discordsrv/common/config/configurate/serializer/EnumSerializer.java index 7748a281..f49a175c 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/serializer/EnumSerializer.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/serializer/EnumSerializer.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.configurate.serializer; import com.discordsrv.common.logging.Logger; diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/serializer/MinecraftMessageSerializer.java b/common/src/main/java/com/discordsrv/common/config/configurate/serializer/MinecraftMessageSerializer.java index 18db836f..fe2e6b7b 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/serializer/MinecraftMessageSerializer.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/serializer/MinecraftMessageSerializer.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.configurate.serializer; import com.discordsrv.common.config.helper.MinecraftMessage; diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/serializer/PatternSerializer.java b/common/src/main/java/com/discordsrv/common/config/configurate/serializer/PatternSerializer.java index c8a35716..8bfbb25e 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/serializer/PatternSerializer.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/serializer/PatternSerializer.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/configurate/serializer/SendableDiscordMessageSerializer.java b/common/src/main/java/com/discordsrv/common/config/configurate/serializer/SendableDiscordMessageSerializer.java index a3a8fa26..f9f27a9d 100644 --- a/common/src/main/java/com/discordsrv/common/config/configurate/serializer/SendableDiscordMessageSerializer.java +++ b/common/src/main/java/com/discordsrv/common/config/configurate/serializer/SendableDiscordMessageSerializer.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/connection/BotConfig.java b/common/src/main/java/com/discordsrv/common/config/connection/BotConfig.java index b17f09a2..417c2d05 100644 --- a/common/src/main/java/com/discordsrv/common/config/connection/BotConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/connection/BotConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/connection/ConnectionConfig.java b/common/src/main/java/com/discordsrv/common/config/connection/ConnectionConfig.java index 90017d14..e3cfff2d 100644 --- a/common/src/main/java/com/discordsrv/common/config/connection/ConnectionConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/connection/ConnectionConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/connection/MinecraftAuthConfig.java b/common/src/main/java/com/discordsrv/common/config/connection/MinecraftAuthConfig.java index a87d9b7d..34de3cbe 100644 --- a/common/src/main/java/com/discordsrv/common/config/connection/MinecraftAuthConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/connection/MinecraftAuthConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/connection/StorageConfig.java b/common/src/main/java/com/discordsrv/common/config/connection/StorageConfig.java index f0b7f18f..728b85e1 100644 --- a/common/src/main/java/com/discordsrv/common/config/connection/StorageConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/connection/StorageConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/connection/UpdateConfig.java b/common/src/main/java/com/discordsrv/common/config/connection/UpdateConfig.java index c1efd50e..b2a3c48b 100644 --- a/common/src/main/java/com/discordsrv/common/config/connection/UpdateConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/connection/UpdateConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/documentation/DocumentationURLs.java b/common/src/main/java/com/discordsrv/common/config/documentation/DocumentationURLs.java index e6da4012..39edc366 100644 --- a/common/src/main/java/com/discordsrv/common/config/documentation/DocumentationURLs.java +++ b/common/src/main/java/com/discordsrv/common/config/documentation/DocumentationURLs.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.documentation; public final class DocumentationURLs { diff --git a/common/src/main/java/com/discordsrv/common/config/helper/MinecraftMessage.java b/common/src/main/java/com/discordsrv/common/config/helper/MinecraftMessage.java index c5e7fab7..b2168c37 100644 --- a/common/src/main/java/com/discordsrv/common/config/helper/MinecraftMessage.java +++ b/common/src/main/java/com/discordsrv/common/config/helper/MinecraftMessage.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.helper; import com.discordsrv.api.DiscordSRVApi; diff --git a/common/src/main/java/com/discordsrv/common/config/main/AvatarProviderConfig.java b/common/src/main/java/com/discordsrv/common/config/main/AvatarProviderConfig.java index 6b472231..67ba4390 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/AvatarProviderConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/AvatarProviderConfig.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.main; import com.discordsrv.common.config.configurate.annotation.Constants; diff --git a/common/src/main/java/com/discordsrv/common/config/main/ConsoleConfig.java b/common/src/main/java/com/discordsrv/common/config/main/ConsoleConfig.java index 5089aa84..542f4a1f 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/ConsoleConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/ConsoleConfig.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.main; import com.discordsrv.common.config.main.generic.DestinationConfig; @@ -91,7 +109,8 @@ public class ConsoleConfig { ); } - @Comment("If command execution is enabled") + @Comment("If command execution in this console channel is enabled\n" + + "Requires the \"Message Content Intent\"") public boolean enabled = true; @Comment("At least one condition has to match to allow execution") diff --git a/common/src/main/java/com/discordsrv/common/config/main/DebugConfig.java b/common/src/main/java/com/discordsrv/common/config/main/DebugConfig.java index 415c126f..c6bcb2b2 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/DebugConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/DebugConfig.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.main; import com.discordsrv.common.config.configurate.annotation.Constants; diff --git a/common/src/main/java/com/discordsrv/common/config/main/DiscordCommandConfig.java b/common/src/main/java/com/discordsrv/common/config/main/DiscordCommandConfig.java index 89d65904..433051c9 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/DiscordCommandConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/DiscordCommandConfig.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.main; import com.discordsrv.common.config.configurate.annotation.Constants; diff --git a/common/src/main/java/com/discordsrv/common/config/main/DiscordInviteConfig.java b/common/src/main/java/com/discordsrv/common/config/main/DiscordInviteConfig.java index 8956e712..eff1c393 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/DiscordInviteConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/DiscordInviteConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -27,10 +27,14 @@ public class DiscordInviteConfig { @Comment("Manually enter a invite url here, if this isn't set this is ignored and the options below will take effect") public String inviteUrl = ""; - @Comment("If the bot is only in one Discord server, it will attempt to get its vanity url") + @Comment("The server id to automatically grab the vanity url from or to generate the invite to.\n" + + "If this is not specified and the bot is private and only in a single server, it will use that") + public long serverId = 0L; + + @Comment("If the bot should automatically use the vanity invite url from the automatically determined server, if one is set") public boolean attemptToUseVanityUrl = true; - @Comment("If the bot is only in one Discord server, it will attempt to automatically create a invite for it.\n" + @Comment("If the bot should automatically create a invite to the automatically determined server\n" + "The bot will only attempt to do so if it has permission to \"Create Invite\"\n" + "The server must also have a rules channel (available for community servers) or default channel (automatically determined by Discord)") public boolean autoCreateInvite = false; diff --git a/common/src/main/java/com/discordsrv/common/config/main/GameCommandConfig.java b/common/src/main/java/com/discordsrv/common/config/main/GameCommandConfig.java index 0d84c051..df9f7e7b 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/GameCommandConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/GameCommandConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/GroupSyncConfig.java b/common/src/main/java/com/discordsrv/common/config/main/GroupSyncConfig.java index 392d7510..b38765d5 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/GroupSyncConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/GroupSyncConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/MainConfig.java b/common/src/main/java/com/discordsrv/common/config/main/MainConfig.java index 65c7c9b1..0dd92013 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/MainConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/MainConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -38,14 +38,19 @@ public abstract class MainConfig implements Config { public static final String FILE_NAME = "config.yaml"; - @Constants({DocumentationURLs.ELT_FORMAT, DocumentationURLs.DISCORD_MARKDOWN, DocumentationURLs.PLACEHOLDERS}) + @Constants({ + ConnectionConfig.FILE_NAME, + DocumentationURLs.ELT_FORMAT, + DocumentationURLs.DISCORD_MARKDOWN, + DocumentationURLs.PLACEHOLDERS + }) public static final String HEADER = String.join("\n", Arrays.asList( "Welcome to the DiscordSRV configuration file", "", - "Looking for the \"BotToken\" option? It has been moved into the " + ConnectionConfig.FILE_NAME, - "Need help with the format for Minecraft messages? %1", - "Need help with Discord markdown? %2", - "List of placeholders %3" + "Looking for the \"BotToken\" option? It has been moved into the %1", + "Need help with the format for Minecraft messages? %2", + "Need help with Discord markdown? %3", + "List of placeholders %4" )); @Override diff --git a/common/src/main/java/com/discordsrv/common/config/main/MemberCachingConfig.java b/common/src/main/java/com/discordsrv/common/config/main/MemberCachingConfig.java index e0121056..270e6aa1 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/MemberCachingConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/MemberCachingConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -27,13 +27,16 @@ import java.util.List; @ConfigSerializable public class MemberCachingConfig { - @Comment("If linked users' members should be cached, this requires the \"Server Members Intent\"") + @Comment("If linked users' members should be cached\n" + + "Requires the \"Server Members Intent\"") public boolean linkedUsers = true; - @Comment("If all members should be cached, this requires the \"Server Members Intent\"") + @Comment("If all members should be cached\n" + + "Requires the \"Server Members Intent\"") public boolean all = false; - @Comment("If members should be cached at startup, this requires the \"Server Members Intent\"") + @Comment("If members should be cached at startup\n" + + "Requires the \"Server Members Intent\"") public boolean chunk = true; @Comment("Filter for which servers should be cached at startup") diff --git a/common/src/main/java/com/discordsrv/common/config/main/MessagesMainConfig.java b/common/src/main/java/com/discordsrv/common/config/main/MessagesMainConfig.java index 685b2d7f..3062b5f0 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/MessagesMainConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/MessagesMainConfig.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.main; import org.spongepowered.configurate.objectmapping.ConfigSerializable; diff --git a/common/src/main/java/com/discordsrv/common/config/main/PluginIntegrationConfig.java b/common/src/main/java/com/discordsrv/common/config/main/PluginIntegrationConfig.java index e7cfea4a..02c3bc24 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/PluginIntegrationConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/PluginIntegrationConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/TimedUpdaterConfig.java b/common/src/main/java/com/discordsrv/common/config/main/TimedUpdaterConfig.java index fdee5099..f0d3fd51 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/TimedUpdaterConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/TimedUpdaterConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/ChannelLockingConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/ChannelLockingConfig.java index f3fe477f..db8c8941 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/ChannelLockingConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/ChannelLockingConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -52,10 +52,10 @@ public class ChannelLockingConfig { public static class Threads { @Comment("If the configured threads should be archived while the server is shutdown") - public boolean archive = true; + public boolean archive = false; - @Comment("If the bot should attempt to unarchive threads rather than make new threads") - public boolean unarchive = true; + @Comment("If the configured threads should be locked while the server is shutdown") + public boolean lock = true; } diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/DiscordToMinecraftChatConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/DiscordToMinecraftChatConfig.java index 27511036..f869bbda 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/DiscordToMinecraftChatConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/DiscordToMinecraftChatConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -31,6 +31,7 @@ import java.util.regex.Pattern; @ConfigSerializable public class DiscordToMinecraftChatConfig { + @Comment("Requires the \"Message Content Intent\"") public boolean enabled = true; @Comment("The Discord to Minecraft message format for regular users and bots") diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/JoinMessageConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/JoinMessageConfig.java index 4b43fa31..c25f611d 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/JoinMessageConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/JoinMessageConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -46,6 +46,9 @@ public class JoinMessageConfig implements IMessageConfig { @Constants.Comment("discordsrv.silentjoin") public boolean enableSilentPermission = true; + @Comment("Ignore if the player leaves within the given amount of milliseconds. This will delay sending the join message") + public long ignoreIfLeftWithinMS = 250; + @Override public boolean enabled() { return enabled; diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/LeaveMessageConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/LeaveMessageConfig.java index 21d44fe7..e5371d79 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/LeaveMessageConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/LeaveMessageConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -44,6 +44,9 @@ public class LeaveMessageConfig implements IMessageConfig { @Constants.Comment("discordsrv.silentquit") public boolean enableSilentPermission = true; + @Comment("Ignore if the player joined within the given amount of milliseconds") + public long ignoreIfJoinedWithinMS = 250; + @Override public boolean enabled() { return enabled; diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/MinecraftToDiscordChatConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/MinecraftToDiscordChatConfig.java index 37f3e2c3..607e28ed 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/MinecraftToDiscordChatConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/MinecraftToDiscordChatConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -70,7 +70,8 @@ public class MinecraftToDiscordChatConfig implements IMessageConfig { public boolean channels = true; @Comment("If user mentions should be rendered on Discord\n" - + "The player needs the discordsrv.mention.user permission to trigger a notification") + + "The player needs the discordsrv.mention.user permission to trigger a notification\n" + + "Requires the \"Server Members Intent\"") public boolean users = true; @Comment("If uncached users should be looked up from the Discord API when a mention (\"@something\") occurs in chat.\n" diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/MirroringConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/MirroringConfig.java index b9adbe56..cfafea3b 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/MirroringConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/MirroringConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -25,6 +25,7 @@ import org.spongepowered.configurate.objectmapping.meta.Comment; @ConfigSerializable public class MirroringConfig { + @Comment("Requires the \"Message Content Intent\"") public boolean enabled = true; @Comment("Users, bots, roles and webhooks to ignore when mirroring") diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/StartMessageConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/StartMessageConfig.java index 8ca8a19f..88bf4076 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/StartMessageConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/StartMessageConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/StopMessageConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/StopMessageConfig.java index 63b2a077..dfbb07f5 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/StopMessageConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/StopMessageConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/base/BaseChannelConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/base/BaseChannelConfig.java index c71ebbb2..5d21d633 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/base/BaseChannelConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/base/BaseChannelConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -28,6 +28,7 @@ public class BaseChannelConfig { @Order(0) public MinecraftToDiscordChatConfig minecraftToDiscord = new MinecraftToDiscordChatConfig(); + @Order(0) public DiscordToMinecraftChatConfig discordToMinecraft = new DiscordToMinecraftChatConfig(); diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/base/ChannelConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/base/ChannelConfig.java index 57906d3c..0dd596de 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/base/ChannelConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/base/ChannelConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/base/IChannelConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/base/IChannelConfig.java index 5202f3c4..e3a1f1c1 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/base/IChannelConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/base/IChannelConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/base/proxy/ProxyBaseChannelConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/base/proxy/ProxyBaseChannelConfig.java index ddd0eca9..283f673e 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/base/proxy/ProxyBaseChannelConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/base/proxy/ProxyBaseChannelConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/base/proxy/ProxyChannelConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/base/proxy/ProxyChannelConfig.java index d83468c6..a5bef9e0 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/base/proxy/ProxyChannelConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/base/proxy/ProxyChannelConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/base/server/ServerBaseChannelConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/base/server/ServerBaseChannelConfig.java index 617d2d90..3627f230 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/base/server/ServerBaseChannelConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/base/server/ServerBaseChannelConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/base/server/ServerChannelConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/base/server/ServerChannelConfig.java index 1aea6d53..4ea77703 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/base/server/ServerChannelConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/base/server/ServerChannelConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/proxy/ServerSwitchMessageConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/proxy/ServerSwitchMessageConfig.java index 5bd1914f..2281b0d8 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/proxy/ServerSwitchMessageConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/proxy/ServerSwitchMessageConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/server/AwardMessageConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/server/AwardMessageConfig.java index f6c91bb0..ce5b6bc1 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/server/AwardMessageConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/server/AwardMessageConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/server/DeathMessageConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/server/DeathMessageConfig.java index 0247708a..a8863407 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/server/DeathMessageConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/server/DeathMessageConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/channels/server/ServerJoinMessageConfig.java b/common/src/main/java/com/discordsrv/common/config/main/channels/server/ServerJoinMessageConfig.java index 4cf63838..f1aea093 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/channels/server/ServerJoinMessageConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/channels/server/ServerJoinMessageConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/generic/DestinationConfig.java b/common/src/main/java/com/discordsrv/common/config/main/generic/DestinationConfig.java index cbbd7cc7..56835978 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/generic/DestinationConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/generic/DestinationConfig.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.main.generic; import com.discordsrv.common.config.configurate.annotation.Constants; diff --git a/common/src/main/java/com/discordsrv/common/config/main/generic/DiscordIgnoresConfig.java b/common/src/main/java/com/discordsrv/common/config/main/generic/DiscordIgnoresConfig.java index 4a0650db..5308254b 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/generic/DiscordIgnoresConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/generic/DiscordIgnoresConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/generic/GameCommandExecutionConditionConfig.java b/common/src/main/java/com/discordsrv/common/config/main/generic/GameCommandExecutionConditionConfig.java index 0a874504..edc1c1da 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/generic/GameCommandExecutionConditionConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/generic/GameCommandExecutionConditionConfig.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.main.generic; import com.discordsrv.api.discord.entity.DiscordUser; diff --git a/common/src/main/java/com/discordsrv/common/config/main/generic/IMessageConfig.java b/common/src/main/java/com/discordsrv/common/config/main/generic/IMessageConfig.java index cde94804..67337879 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/generic/IMessageConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/generic/IMessageConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/generic/MentionsConfig.java b/common/src/main/java/com/discordsrv/common/config/main/generic/MentionsConfig.java index 5cb76610..320e00fb 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/generic/MentionsConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/generic/MentionsConfig.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.main.generic; import com.discordsrv.common.config.configurate.annotation.Untranslated; diff --git a/common/src/main/java/com/discordsrv/common/config/main/generic/ThreadConfig.java b/common/src/main/java/com/discordsrv/common/config/main/generic/ThreadConfig.java index a6b2109d..efd2aa4d 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/generic/ThreadConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/generic/ThreadConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -26,7 +26,13 @@ public class ThreadConfig { @Comment("Specify the text or forum channel id and the name of the thread (the thread will be automatically created if it doesn't exist)") public Long channelId = 0L; + public String threadName = "Minecraft Server chat bridge"; + + @Comment("Should an existing thread with the same name be unarchived instead of creating a new thread every time") + public boolean unarchiveExisting = true; + + @Comment("Does not effect forums") public boolean privateThread = false; } diff --git a/common/src/main/java/com/discordsrv/common/config/main/linking/LinkedAccountConfig.java b/common/src/main/java/com/discordsrv/common/config/main/linking/LinkedAccountConfig.java index 9c8f605f..84c1814e 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/linking/LinkedAccountConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/linking/LinkedAccountConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/linking/ProxyRequiredLinkingConfig.java b/common/src/main/java/com/discordsrv/common/config/main/linking/ProxyRequiredLinkingConfig.java index ddef51ed..c7dba0e6 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/linking/ProxyRequiredLinkingConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/linking/ProxyRequiredLinkingConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/linking/RequiredLinkingConfig.java b/common/src/main/java/com/discordsrv/common/config/main/linking/RequiredLinkingConfig.java index ef9d605f..7f7a7323 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/linking/RequiredLinkingConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/linking/RequiredLinkingConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/linking/RequirementsConfig.java b/common/src/main/java/com/discordsrv/common/config/main/linking/RequirementsConfig.java index 4f28887f..4dc8e208 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/linking/RequirementsConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/linking/RequirementsConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/main/linking/ServerRequiredLinkingConfig.java b/common/src/main/java/com/discordsrv/common/config/main/linking/ServerRequiredLinkingConfig.java index 19e460ea..4ad53267 100644 --- a/common/src/main/java/com/discordsrv/common/config/main/linking/ServerRequiredLinkingConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/main/linking/ServerRequiredLinkingConfig.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/config/messages/MessagesConfig.java b/common/src/main/java/com/discordsrv/common/config/messages/MessagesConfig.java index fb9fc90b..d23e697d 100644 --- a/common/src/main/java/com/discordsrv/common/config/messages/MessagesConfig.java +++ b/common/src/main/java/com/discordsrv/common/config/messages/MessagesConfig.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config.messages; import com.discordsrv.api.discord.entity.DiscordUser; diff --git a/common/src/main/java/com/discordsrv/common/console/Console.java b/common/src/main/java/com/discordsrv/common/console/Console.java index cd5260b0..43ceecc2 100644 --- a/common/src/main/java/com/discordsrv/common/console/Console.java +++ b/common/src/main/java/com/discordsrv/common/console/Console.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/console/ConsoleModule.java b/common/src/main/java/com/discordsrv/common/console/ConsoleModule.java index 45f8141e..d41fdbbf 100644 --- a/common/src/main/java/com/discordsrv/common/console/ConsoleModule.java +++ b/common/src/main/java/com/discordsrv/common/console/ConsoleModule.java @@ -1,7 +1,27 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.console; import com.discordsrv.api.DiscordSRVApi; import com.discordsrv.api.discord.connection.details.DiscordGatewayIntent; +import com.discordsrv.api.event.bus.Subscribe; +import com.discordsrv.api.event.events.discord.message.DiscordMessageReceiveEvent; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.config.main.ConsoleConfig; import com.discordsrv.common.config.main.generic.DestinationConfig; @@ -15,10 +35,7 @@ import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; +import java.util.*; import java.util.function.Consumer; public class ConsoleModule extends AbstractModule implements LogAppender { @@ -32,7 +49,12 @@ public class ConsoleModule extends AbstractModule implements LogAppe @Override public @NotNull Collection requiredIntents() { - return Collections.singletonList(DiscordGatewayIntent.MESSAGE_CONTENT); + boolean anyExecutors = discordSRV.config().console.stream().anyMatch(config -> config.commandExecution.enabled); + if (anyExecutors) { + return EnumSet.of(DiscordGatewayIntent.GUILD_MESSAGES, DiscordGatewayIntent.MESSAGE_CONTENT); + } + + return Collections.emptySet(); } @Override @@ -83,4 +105,11 @@ public class ConsoleModule extends AbstractModule implements LogAppe handler.queue(entry); } } + + @Subscribe + public void onDiscordMessageReceived(DiscordMessageReceiveEvent event) { + for (SingleConsoleHandler handler : handlers) { + handler.handleDiscordMessageReceived(event); + } + } } diff --git a/common/src/main/java/com/discordsrv/common/console/SingleConsoleHandler.java b/common/src/main/java/com/discordsrv/common/console/SingleConsoleHandler.java index f8666c37..dd9f8824 100644 --- a/common/src/main/java/com/discordsrv/common/console/SingleConsoleHandler.java +++ b/common/src/main/java/com/discordsrv/common/console/SingleConsoleHandler.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.console; import com.discordsrv.api.discord.entity.DiscordUser; @@ -9,7 +27,6 @@ import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessage; import com.discordsrv.api.discord.entity.message.SendableDiscordMessage; import com.discordsrv.api.discord.util.DiscordFormattingUtil; -import com.discordsrv.api.event.bus.Subscribe; import com.discordsrv.api.event.events.discord.message.DiscordMessageReceiveEvent; import com.discordsrv.api.placeholder.PlainPlaceholderFormat; import com.discordsrv.api.placeholder.provider.SinglePlaceholder; @@ -67,11 +84,13 @@ public class SingleConsoleHandler { this.messageCache = config.appender.useEditing ? new ArrayList<>() : null; timeQueueProcess(); - discordSRV.eventBus().subscribe(this); } - @Subscribe - public void onDiscordMessageReceived(DiscordMessageReceiveEvent event) { + public void handleDiscordMessageReceived(DiscordMessageReceiveEvent event) { + if (!config.commandExecution.enabled) { + return; + } + DiscordMessageChannel messageChannel = event.getChannel(); DiscordGuildChannel channel = messageChannel instanceof DiscordGuildChannel ? (DiscordGuildChannel) messageChannel : null; if (channel == null) { @@ -174,7 +193,6 @@ public class SingleConsoleHandler { @SuppressWarnings("SynchronizeOnNonFinalField") public void shutdown() { shutdown = true; - discordSRV.eventBus().unsubscribe(this); queueProcessingFuture.cancel(false); try { synchronized (queueProcessingFuture) { @@ -295,8 +313,8 @@ public class SingleConsoleHandler { sendFuture = future .thenCompose(__ -> - discordSRV.discordAPI() - .findOrCreateDestinations(config.channel.asDestination(), true, true, true) + discordSRV.destinations() + .lookupDestination(config.channel.asDestination(), true, true) ) .thenApply(channels -> { if (channels.isEmpty()) { diff --git a/common/src/main/java/com/discordsrv/common/console/entry/LogEntry.java b/common/src/main/java/com/discordsrv/common/console/entry/LogEntry.java index 2d42b75e..5ee35f6c 100644 --- a/common/src/main/java/com/discordsrv/common/console/entry/LogEntry.java +++ b/common/src/main/java/com/discordsrv/common/console/entry/LogEntry.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.console.entry; import com.discordsrv.api.placeholder.annotation.Placeholder; diff --git a/common/src/main/java/com/discordsrv/common/console/entry/LogMessage.java b/common/src/main/java/com/discordsrv/common/console/entry/LogMessage.java index 5c843cd3..ee1551e6 100644 --- a/common/src/main/java/com/discordsrv/common/console/entry/LogMessage.java +++ b/common/src/main/java/com/discordsrv/common/console/entry/LogMessage.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.console.entry; /** diff --git a/common/src/main/java/com/discordsrv/common/console/message/ConsoleMessage.java b/common/src/main/java/com/discordsrv/common/console/message/ConsoleMessage.java index ce05fd90..9c4eb9f0 100644 --- a/common/src/main/java/com/discordsrv/common/console/message/ConsoleMessage.java +++ b/common/src/main/java/com/discordsrv/common/console/message/ConsoleMessage.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.console.message; import com.discordsrv.common.DiscordSRV; diff --git a/common/src/main/java/com/discordsrv/common/debug/DebugGenerateEvent.java b/common/src/main/java/com/discordsrv/common/debug/DebugGenerateEvent.java index f0db5701..1dade15d 100644 --- a/common/src/main/java/com/discordsrv/common/debug/DebugGenerateEvent.java +++ b/common/src/main/java/com/discordsrv/common/debug/DebugGenerateEvent.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/debug/DebugReport.java b/common/src/main/java/com/discordsrv/common/debug/DebugReport.java index 3c8b0704..07168b90 100644 --- a/common/src/main/java/com/discordsrv/common/debug/DebugReport.java +++ b/common/src/main/java/com/discordsrv/common/debug/DebugReport.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -53,6 +53,8 @@ import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import static com.discordsrv.common.command.combined.commands.DebugCommand.KEY_ENCODER; + public class DebugReport { private static final int BIG_FILE_SPLIT_SIZE = 50000; @@ -101,7 +103,7 @@ public class DebugReport { try { Paste paste = service.uploadFile(convertToJson(file).toString().getBytes(StandardCharsets.UTF_8)); node.put("url", paste.url()); - node.put("decryption_key", new String(Base64.getUrlEncoder().encode(paste.decryptionKey()), StandardCharsets.UTF_8)); + node.put("decryption_key", new String(KEY_ENCODER.encode(paste.decryptionKey()), StandardCharsets.UTF_8)); node.put("length", length); } catch (Throwable e) { node.put("content", "Failed to upload file\n\n" + ExceptionUtils.getStackTrace(e)); @@ -215,7 +217,7 @@ public class DebugReport { manager.save(loader); return new TextDebugFile(order, fileName, writer.toString()); - } catch (IOException | ConfigException e) { + } catch (Exception e) { return exception(order, fileName, e); } } diff --git a/common/src/main/java/com/discordsrv/common/debug/data/OnlineMode.java b/common/src/main/java/com/discordsrv/common/debug/data/OnlineMode.java index 2e2a1912..a200e4e8 100644 --- a/common/src/main/java/com/discordsrv/common/debug/data/OnlineMode.java +++ b/common/src/main/java/com/discordsrv/common/debug/data/OnlineMode.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/debug/data/VersionInfo.java b/common/src/main/java/com/discordsrv/common/debug/data/VersionInfo.java index e958b015..de62fd6f 100644 --- a/common/src/main/java/com/discordsrv/common/debug/data/VersionInfo.java +++ b/common/src/main/java/com/discordsrv/common/debug/data/VersionInfo.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/debug/file/DebugFile.java b/common/src/main/java/com/discordsrv/common/debug/file/DebugFile.java index b88cdd92..22607e14 100644 --- a/common/src/main/java/com/discordsrv/common/debug/file/DebugFile.java +++ b/common/src/main/java/com/discordsrv/common/debug/file/DebugFile.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/debug/file/KeyValueDebugFile.java b/common/src/main/java/com/discordsrv/common/debug/file/KeyValueDebugFile.java index de56b681..72f08d7e 100644 --- a/common/src/main/java/com/discordsrv/common/debug/file/KeyValueDebugFile.java +++ b/common/src/main/java/com/discordsrv/common/debug/file/KeyValueDebugFile.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/debug/file/TextDebugFile.java b/common/src/main/java/com/discordsrv/common/debug/file/TextDebugFile.java index 5c97b2e2..b6906fab 100644 --- a/common/src/main/java/com/discordsrv/common/debug/file/TextDebugFile.java +++ b/common/src/main/java/com/discordsrv/common/debug/file/TextDebugFile.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/dependency/DependencyLoader.java b/common/src/main/java/com/discordsrv/common/dependency/DependencyLoader.java index 12993f4f..e78edb03 100644 --- a/common/src/main/java/com/discordsrv/common/dependency/DependencyLoader.java +++ b/common/src/main/java/com/discordsrv/common/dependency/DependencyLoader.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -87,19 +87,31 @@ public class DependencyLoader { return dependencyManager; } - public IsolatedClassLoader loadIntoIsolated() throws IOException { + public IsolatedClassLoader intoIsolated() throws IOException { IsolatedClassLoader classLoader = new IsolatedClassLoader(); - download(classLoader).join(); + downloadRelocateAndLoad(classLoader).join(); return classLoader; } - public CompletableFuture download() { - return download(classpathAppender); + public CompletableFuture downloadRelocateAndLoad() { + return downloadRelocateAndLoad(classpathAppender); } - private CompletableFuture download(ClasspathAppender appender) { - return dependencyManager.downloadAll(executor, REPOSITORIES) - .thenCompose(v -> dependencyManager.relocateAll(executor)) - .thenCompose(v -> dependencyManager.loadAll(executor, appender)); + public CompletableFuture downloadRelocateAndLoad(ClasspathAppender appender) { + return download().thenCompose(v -> relocateAndLoad(true, appender)); + } + + public CompletableFuture download() { + return dependencyManager.downloadAll(executor, REPOSITORIES); + } + + public CompletableFuture relocateAndLoad(boolean useExecutor) { + return relocateAndLoad(useExecutor, classpathAppender); + } + + public CompletableFuture relocateAndLoad(boolean useExecutor, ClasspathAppender appender) { + Executor executorToUse = useExecutor ? executor : null; + return dependencyManager.relocateAll(executorToUse) + .thenCompose(v -> dependencyManager.loadAll(executorToUse, appender)); } } diff --git a/common/src/main/java/com/discordsrv/common/dependency/DiscordSRVDependencyManager.java b/common/src/main/java/com/discordsrv/common/dependency/DiscordSRVDependencyManager.java index b9ca7dec..18a10da8 100644 --- a/common/src/main/java/com/discordsrv/common/dependency/DiscordSRVDependencyManager.java +++ b/common/src/main/java/com/discordsrv/common/dependency/DiscordSRVDependencyManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/destination/DestinationLookupHelper.java b/common/src/main/java/com/discordsrv/common/destination/DestinationLookupHelper.java new file mode 100644 index 00000000..4c02ae9a --- /dev/null +++ b/common/src/main/java/com/discordsrv/common/destination/DestinationLookupHelper.java @@ -0,0 +1,247 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + +package com.discordsrv.common.destination; + +import com.discordsrv.api.discord.entity.channel.*; +import com.discordsrv.api.discord.entity.message.SendableDiscordMessage; +import com.discordsrv.common.DiscordSRV; +import com.discordsrv.common.config.main.generic.DestinationConfig; +import com.discordsrv.common.config.main.generic.ThreadConfig; +import com.discordsrv.common.discord.util.DiscordPermissionUtil; +import com.discordsrv.common.logging.Logger; +import com.discordsrv.common.logging.NamedLogger; +import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer; +import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; +import org.apache.commons.lang3.StringUtils; + +import java.util.*; +import java.util.concurrent.CompletableFuture; + +public class DestinationLookupHelper { + + private final DiscordSRV discordSRV; + private final Logger logger; + private final Map> threadActions = new HashMap<>(); + + public DestinationLookupHelper(DiscordSRV discordSRV) { + this.discordSRV = discordSRV; + this.logger = new NamedLogger(discordSRV, "DESTINATION_LOOKUP"); + } + + public CompletableFuture> lookupDestination( + DestinationConfig config, + boolean allowRequests, + boolean logFailures + ) { + List> futures = new ArrayList<>(); + + for (Long channelId : config.channelIds) { + if (channelId == 0) { + continue; + } + + DiscordMessageChannel channel = discordSRV.discordAPI().getMessageChannelById(channelId); + if (channel == null) { + if (logFailures) { + logger.error("Channel with ID " + Long.toUnsignedString(channelId) + " not found"); + } + continue; + } + if (!(channel instanceof DiscordGuildMessageChannel)) { + continue; + } + futures.add(CompletableFuture.completedFuture((DiscordGuildMessageChannel) channel)); + } + + for (ThreadConfig threadConfig : config.threads) { + long channelId = threadConfig.channelId; + if (channelId == 0 || StringUtils.isEmpty(threadConfig.threadName)) { + continue; + } + + DiscordThreadContainer threadContainer; + DiscordMessageChannel messageChannel = discordSRV.discordAPI().getMessageChannelById(channelId); + if (messageChannel instanceof DiscordThreadContainer) { + threadContainer = (DiscordThreadContainer) messageChannel; + } else { + threadContainer = discordSRV.discordAPI().getForumChannelById(channelId); + } + if (threadContainer == null) { + if (logFailures) { + logger.error("Channel with ID " + Long.toUnsignedString(channelId) + " not found"); + } + continue; + } + + DiscordThreadChannel existingThread = findThread(threadContainer.getActiveThreads(), threadConfig); + if (existingThread != null && !existingThread.isArchived()) { + futures.add(CompletableFuture.completedFuture(existingThread)); + continue; + } + + if (!allowRequests) { + continue; + } + + String threadKey = Long.toUnsignedString(channelId) + ":" + threadConfig.threadName + "/" + threadConfig.privateThread; + + CompletableFuture future; + synchronized (threadActions) { + CompletableFuture existingFuture = threadActions.get(threadKey); + + if (existingFuture != null) { + future = existingFuture; + } else if (!threadConfig.unarchiveExisting) { + // Unarchiving not allowed, create new + future = createThread(threadContainer, threadConfig, logFailures); + } else if (existingThread != null) { + // Unarchive existing thread + future = unarchiveThread(existingThread, logFailures); + } else { + // Lookup threads + CompletableFuture> threads = + threadConfig.privateThread + ? threadContainer.retrieveArchivedPrivateThreads() + : threadContainer.retrieveArchivedPublicThreads(); + + future = threads.thenCompose(archivedThreads -> { + DiscordThreadChannel archivedThread = findThread(archivedThreads, threadConfig); + if (archivedThread != null) { + // Unarchive existing thread + return unarchiveThread(archivedThread, logFailures); + } + + // Create thread + return createThread(threadContainer, threadConfig, logFailures); + }).exceptionally(t -> { + if (logFailures) { + logger.error("Failed to lookup threads in channel #" + threadContainer.getName(), t); + } + return null; + }); + } + + if (future != existingFuture) { + threadActions.put(threadKey, future); + future.whenComplete((v, t) -> threadActions.remove(threadKey)); + } + } + futures.add(future); + } + + //noinspection rawtypes + return CompletableFuture.allOf( + futures.stream() + .map(future -> (CompletableFuture) future) + .toArray(CompletableFuture[]::new) + ).thenApply(v -> { + Set idsDuplicateCheck = new HashSet<>(); + List channels = new ArrayList<>(); + + for (CompletableFuture future : futures) { + DiscordGuildMessageChannel channel = future.join(); + if (channel != null && idsDuplicateCheck.add(channel.getId())) { + channels.add(channel); + } + } + return channels; + }); + } + + private DiscordThreadChannel findThread(Collection threads, ThreadConfig config) { + for (DiscordThreadChannel thread : threads) { + if (thread.getName().equals(config.threadName)) { + return thread; + } + } + return null; + } + + private CompletableFuture createThread( + DiscordThreadContainer threadContainer, + ThreadConfig threadConfig, + boolean logFailures + ) { + boolean forum = threadContainer instanceof DiscordForumChannel; + boolean privateThread = !forum && threadConfig.privateThread; + + IThreadContainer container = threadContainer.getAsJDAThreadContainer(); + String missingPermissions = DiscordPermissionUtil.missingPermissionsString( + container, + Permission.VIEW_CHANNEL, + privateThread ? Permission.CREATE_PRIVATE_THREADS : Permission.CREATE_PUBLIC_THREADS + ); + if (missingPermissions != null) { + if (logFailures) { + logger.error("Failed to create thread \"" + threadConfig.threadName + "\" " + + "in channel #" + threadContainer.getName() + ": " + missingPermissions); + } + return CompletableFuture.completedFuture(null); + } + + CompletableFuture future; + if (forum) { + future = ((DiscordForumChannel) threadContainer).createPost( + threadConfig.threadName, + SendableDiscordMessage.builder().setContent("\u200B").build() // zero-width-space + ); + } else { + future = threadContainer.createThread(threadConfig.threadName, privateThread); + } + return future.exceptionally(t -> { + if (logFailures) { + logger.error("Failed to create thread \"" + threadConfig.threadName + "\" " + + "in channel #" + threadContainer.getName(), t); + } + return null; + }); + } + + private CompletableFuture unarchiveThread(DiscordThreadChannel channel, boolean logFailures) { + ThreadChannel jdaChannel = channel.asJDA(); + + EnumSet requiredPermissions = EnumSet.of(Permission.VIEW_CHANNEL); + if (jdaChannel.isLocked() || !jdaChannel.isOwner()) { + requiredPermissions.add(Permission.MANAGE_THREADS); + } + + String missingPermissions = DiscordPermissionUtil.missingPermissionsString(jdaChannel, requiredPermissions); + if (missingPermissions != null) { + if (logFailures) { + logger.error("Cannot unarchive thread \"" + channel.getName() + "\" " + + "in channel #" + channel.getParentChannel().getName() + ": " + missingPermissions); + } + return CompletableFuture.completedFuture(null); + } + + return discordSRV.discordAPI().mapExceptions( + channel.asJDA().getManager() + .setArchived(false) + .reason("DiscordSRV destination lookup") + .submit() + ).thenApply(v -> channel).exceptionally(t -> { + if (logFailures) { + logger.error("Failed to unarchive thread \"" + channel.getName() + "\" " + + "in channel #" + channel.getParentChannel().getName(), t); + } + return null; + }); + } +} diff --git a/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIEventModule.java b/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIEventModule.java index 467555a2..750e830b 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIEventModule.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIEventModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -18,6 +18,7 @@ package com.discordsrv.common.discord.api; +import com.discordsrv.api.discord.connection.details.DiscordGatewayIntent; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuildMember; @@ -37,6 +38,7 @@ import com.discordsrv.api.event.events.discord.member.role.DiscordMemberRoleRemo import com.discordsrv.api.event.events.discord.message.DiscordMessageDeleteEvent; import com.discordsrv.api.event.events.discord.message.DiscordMessageReceiveEvent; import com.discordsrv.api.event.events.discord.message.DiscordMessageUpdateEvent; +import com.discordsrv.api.module.Module; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.discord.api.entity.component.DiscordInteractionHookImpl; import com.discordsrv.common.discord.api.entity.message.ReceivedDiscordMessageImpl; @@ -59,10 +61,9 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.message.MessageUpdateEvent; import net.dv8tion.jda.api.interactions.callbacks.IDeferrableCallback; import net.dv8tion.jda.api.interactions.commands.Command; +import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -76,6 +77,15 @@ public class DiscordAPIEventModule extends AbstractModule { return discordSRV.discordAPI(); } + /** + * See {@link Module#requiredIntents()} implementation. + * @return no intents as these events might not be listened to + */ + @Override + public @NotNull Collection requiredIntents() { + return Collections.emptyList(); + } + @Subscribe public void onMessageReceived(MessageReceivedEvent event) { discordSRV.eventBus().publish(new DiscordMessageReceiveEvent( diff --git a/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIImpl.java index 04cdb967..e0d7c7e4 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/DiscordAPIImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -20,7 +20,6 @@ package com.discordsrv.common.discord.api; import com.discordsrv.api.discord.DiscordAPI; import com.discordsrv.api.discord.connection.details.DiscordGatewayIntent; -import com.discordsrv.api.discord.connection.jda.errorresponse.ErrorCallbackContext; import com.discordsrv.api.discord.entity.DiscordUser; import com.discordsrv.api.discord.entity.channel.*; import com.discordsrv.api.discord.entity.guild.DiscordCustomEmoji; @@ -49,7 +48,9 @@ import com.github.benmanes.caffeine.cache.Expiry; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.*; import net.dv8tion.jda.api.entities.channel.Channel; +import net.dv8tion.jda.api.entities.channel.attribute.IWebhookContainer; import net.dv8tion.jda.api.entities.channel.concrete.*; +import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; import net.dv8tion.jda.api.entities.emoji.CustomEmoji; import net.dv8tion.jda.api.exceptions.ErrorResponseException; @@ -59,10 +60,11 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; -import java.util.concurrent.*; -import java.util.function.BiConsumer; -import java.util.function.Consumer; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import java.util.concurrent.TimeUnit; import java.util.function.Function; public class DiscordAPIImpl implements DiscordAPI { @@ -70,7 +72,6 @@ public class DiscordAPIImpl implements DiscordAPI { private final DiscordSRV discordSRV; private final DiscordCommandRegistry commandRegistry; private final AsyncLoadingCache> cachedClients; - private final List threadLookups = new CopyOnWriteArrayList<>(); public DiscordAPIImpl(DiscordSRV discordSRV) { this.discordSRV = discordSRV; @@ -88,227 +89,6 @@ public class DiscordAPIImpl implements DiscordAPI { return cachedClients; } - public Collection findDestinations( - T config, - boolean log - ) { - return findOrCreateDestinations(config, false, log).join(); - } - - public CompletableFuture> findOrCreateDestinations( - T config, - boolean create, - boolean log - ) { - return findOrCreateDestinations(config.destination(), config.channelLocking.threads.unarchive, create, log); - } - - public CompletableFuture> findOrCreateDestinations( - DestinationConfig destination, - boolean unarchive, - boolean create, - boolean log - ) { - Set channels = new HashSet<>(); - for (Long channelId : destination.channelIds) { - DiscordMessageChannel channel = getMessageChannelById(channelId); - if (!(channel instanceof DiscordGuildMessageChannel)) { - continue; - } - synchronized (channels) { - channels.add((DiscordGuildMessageChannel) channel); - } - } - - List> threadFutures = new ArrayList<>(); - List threadConfigs = destination.threads; - if (threadConfigs != null && !threadConfigs.isEmpty()) { - for (ThreadConfig threadConfig : threadConfigs) { - long channelId = threadConfig.channelId; - DiscordThreadContainer channel = getTextChannelById(channelId); - if (channel == null) { - channel = getForumChannelById(channelId); - } - if (channel == null) { - if (channelId > 0 && log) { - discordSRV.logger().error("Unable to find channel with ID " + Long.toUnsignedString(channelId)); - } - continue; - } - - // Check if a thread by the same name is still active - DiscordThreadChannel thread = findThread(threadConfig, channel.getActiveThreads()); - if (thread != null) { - if (!thread.isArchived()) { - synchronized (channels) { - channels.add(thread); - } - continue; - } - } - - if (!create) { - continue; - } - - CompletableFuture future; - if (thread != null) { - // Unarchive the thread - future = new CompletableFuture<>(); - unarchiveOrCreateThread(threadConfig, channel, thread, future); - } else { - // Find or create the thread - future = findOrCreateThread(unarchive, threadConfig, channel); - } - - DiscordThreadContainer container = channel; - threadFutures.add(future.handle((threadChannel, t) -> { - if (t != null) { - ErrorCallbackContext.context( - "Failed to deliver message to thread \"" - + threadConfig.threadName + "\" in channel " + container - ).accept(t); - throw new RuntimeException(); // Just here to fail the future - } - - if (threadChannel != null) { - synchronized (channels) { - channels.add(threadChannel); - } - } - return null; - })); - } - } - - return CompletableFutureUtil.combine(threadFutures).thenApply(v -> channels); - } - - private DiscordThreadChannel findThread(ThreadConfig config, List threads) { - for (DiscordThreadChannel thread : threads) { - if (thread.getName().equals(config.threadName)) { - return thread; - } - } - return null; - } - - private CompletableFuture findOrCreateThread(boolean unarchive, ThreadConfig threadConfig, DiscordThreadContainer container) { - if (!unarchive) { - return container.createThread(threadConfig.threadName, threadConfig.privateThread); - } - - CompletableFuture completableFuture = new CompletableFuture<>(); - lookupThreads( - container, - threadConfig.privateThread, - lookup -> findOrCreateThread(threadConfig, container, lookup, completableFuture), - (thread, throwable) -> { - if (throwable != null) { - completableFuture.completeExceptionally(throwable); - } else { - completableFuture.complete(thread); - } - }); - return completableFuture; - } - - private void findOrCreateThread( - ThreadConfig config, - DiscordThreadContainer container, - ThreadChannelLookup lookup, - CompletableFuture completableFuture - ) { - completableFuture.whenComplete((threadChannel, throwable) -> { - CompletableFuture future = lookup.getChannelFuture(); - if (throwable != null) { - future.completeExceptionally(throwable); - } else { - future.complete(threadChannel); - } - }); - lookup.getFuture().whenComplete((channels, throwable) -> { - if (throwable != null) { - completableFuture.completeExceptionally(throwable); - return; - } - - DiscordThreadChannel thread = findThread(config, channels); - unarchiveOrCreateThread(config, container, thread, completableFuture); - }).exceptionally(t -> { - if (t instanceof CompletionException) { - completableFuture.completeExceptionally(t.getCause()); - return null; - } - completableFuture.completeExceptionally(t); - return null; - }); - } - - private void unarchiveOrCreateThread( - ThreadConfig config, - DiscordThreadContainer container, - DiscordThreadChannel thread, - CompletableFuture future - ) { - if (thread != null) { - if (thread.isLocked() || thread.isArchived()) { - try { - thread.asJDA() - .getManager() - .setArchived(false) - .reason("DiscordSRV Auto Unarchive") - .queue(v -> future.complete(thread), future::completeExceptionally); - } catch (Throwable t) { - future.completeExceptionally(t); - } - } else { - future.complete(thread); - } - return; - } - - container.createThread(config.threadName, config.privateThread).whenComplete(((threadChannel, t) -> { - if (t != null) { - future.completeExceptionally(t); - } else { - future.complete(threadChannel); - } - })); - } - - public void lookupThreads( - DiscordThreadContainer container, - boolean privateThreads, - Consumer lookupConsumer, - BiConsumer channelConsumer - ) { - ThreadChannelLookup lookup; - synchronized (threadLookups) { - for (ThreadChannelLookup threadLookup : threadLookups) { - if (threadLookup.isPrivateThreads() != privateThreads - || threadLookup.getChannelId() != container.getId()) { - continue; - } - - threadLookup.getChannelFuture().whenComplete(channelConsumer); - return; - } - - lookup = new ThreadChannelLookup( - container.getId(), privateThreads, - privateThreads - ? container.retrieveArchivedPrivateThreads() - : container.retrieveArchivedPublicThreads() - ); - threadLookups.add(lookup); - } - - lookup.getChannelFuture().whenComplete(channelConsumer); - lookupConsumer.accept(lookup); - lookup.getFuture().whenComplete((channel, t) -> threadLookups.remove(lookup)); - } - public CompletableFuture mapExceptions(CheckedSupplier> futureSupplier) { try { return mapExceptions(futureSupplier.get()); @@ -347,6 +127,16 @@ public class DiscordAPIImpl implements DiscordAPI { return threadChannel; } + DiscordVoiceChannel voiceChannel = getVoiceChannelById(id); + if (voiceChannel != null) { + return voiceChannel; + } + + DiscordNewsChannel newsChannel = getNewsChannelById(id); + if (newsChannel != null) { + return newsChannel; + } + return getDirectMessageChannelById(id); } @@ -369,6 +159,8 @@ public class DiscordAPIImpl implements DiscordAPI { return getDirectMessageChannel((PrivateChannel) jda); } else if (jda instanceof NewsChannel) { return getNewsChannel((NewsChannel) jda); + } else if (jda instanceof VoiceChannel) { + return getVoiceChannel((VoiceChannel) jda); } else { throw new IllegalArgumentException("Unmappable MessageChannel type: " + jda.getClass().getName()); } @@ -538,12 +330,13 @@ public class DiscordAPIImpl implements DiscordAPI { return notReady(); } - TextChannel textChannel = jda.getTextChannelById(channelId); - if (textChannel == null) { + GuildChannel channel = jda.getGuildChannelById(channelId); + IWebhookContainer webhookContainer = channel instanceof IWebhookContainer ? (IWebhookContainer) channel : null; + if (webhookContainer == null) { return CompletableFutureUtil.failed(new IllegalArgumentException("Channel could not be found")); } - return textChannel.retrieveWebhooks().submit().thenApply(webhooks -> { + return webhookContainer.retrieveWebhooks().submit().thenApply(webhooks -> { Webhook hook = null; for (Webhook webhook : webhooks) { User user = webhook.getOwnerAsUser(); @@ -563,7 +356,7 @@ public class DiscordAPIImpl implements DiscordAPI { return CompletableFuture.completedFuture(webhook); } - return textChannel.createWebhook("DSRV").submit(); + return webhookContainer.createWebhook("DSRV").submit(); }).thenApply(webhook -> WebhookClient.createClient( webhook.getJDA(), diff --git a/common/src/main/java/com/discordsrv/common/discord/api/DiscordCommandRegistry.java b/common/src/main/java/com/discordsrv/common/discord/api/DiscordCommandRegistry.java index f7f6314f..44213e46 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/DiscordCommandRegistry.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/DiscordCommandRegistry.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/ThreadChannelLookup.java b/common/src/main/java/com/discordsrv/common/discord/api/ThreadChannelLookup.java deleted file mode 100644 index 568a7185..00000000 --- a/common/src/main/java/com/discordsrv/common/discord/api/ThreadChannelLookup.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 . - */ - -package com.discordsrv.common.discord.api; - -import com.discordsrv.api.discord.entity.channel.DiscordThreadChannel; - -import java.util.List; -import java.util.concurrent.CompletableFuture; - -public class ThreadChannelLookup { - - private final long channelId; - private final boolean privateThreads; - private final CompletableFuture> future; - private final CompletableFuture channelFuture = new CompletableFuture<>(); - - public ThreadChannelLookup(long channelId, boolean privateThreads, CompletableFuture> future) { - this.channelId = channelId; - this.privateThreads = privateThreads; - this.future = future; - } - - public long getChannelId() { - return channelId; - } - - public boolean isPrivateThreads() { - return privateThreads; - } - - public CompletableFuture> getFuture() { - return future; - } - - public CompletableFuture getChannelFuture() { - return channelFuture; - } -} diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/DiscordUserImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/DiscordUserImpl.java index 3b82ac18..1dd00b44 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/DiscordUserImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/DiscordUserImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordGuildMessageChannel.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordGuildMessageChannel.java index 5ce7c977..a12ce6b9 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordGuildMessageChannel.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordGuildMessageChannel.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordMessageChannel.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordMessageChannel.java index 2831a875..527dcda1 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordMessageChannel.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordMessageChannel.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordThreadedGuildMessageChannel.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordThreadedGuildMessageChannel.java index c7a80b29..e1f7b453 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordThreadedGuildMessageChannel.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/AbstractDiscordThreadedGuildMessageChannel.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -100,4 +100,8 @@ public abstract class AbstractDiscordThreadedGuildMessageChannel. + */ + package com.discordsrv.common.discord.api.entity.channel; import com.discordsrv.api.discord.entity.channel.DiscordChannelType; import com.discordsrv.api.discord.entity.channel.DiscordForumChannel; import com.discordsrv.api.discord.entity.channel.DiscordThreadChannel; import com.discordsrv.api.discord.entity.guild.DiscordGuild; +import com.discordsrv.api.discord.entity.message.SendableDiscordMessage; import com.discordsrv.common.DiscordSRV; +import com.discordsrv.common.discord.api.entity.message.util.SendableDiscordMessageUtil; import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer; import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel; import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; -import net.dv8tion.jda.api.requests.restaction.ThreadChannelAction; +import net.dv8tion.jda.api.entities.channel.forums.ForumPost; +import net.dv8tion.jda.api.requests.restaction.AbstractThreadCreateAction; import net.dv8tion.jda.api.requests.restaction.pagination.ThreadChannelPaginationAction; import org.jetbrains.annotations.NotNull; @@ -95,20 +116,36 @@ public class DiscordForumChannelImpl implements DiscordForumChannel { @Override public CompletableFuture createThread(String name, boolean privateThread) { - return thread(channel -> channel.createThreadChannel(name, privateThread)); + throw new IllegalStateException("Cannot create Threads in Forums without a message"); } @Override public CompletableFuture createThread(String name, long messageId) { - return thread(channel -> channel.createThreadChannel(name, messageId)); + return thread(channel -> channel.createThreadChannel(name, messageId), result -> result); + } + + @Override + public IThreadContainer getAsJDAThreadContainer() { + return channel; + } + + @Override + public CompletableFuture createPost(String name, SendableDiscordMessage message) { + return thread( + channel -> channel.createForumPost(name, SendableDiscordMessageUtil.toJDASend(message)), + ForumPost::getThreadChannel + ); } @SuppressWarnings("CodeBlock2Expr") - private CompletableFuture thread(Function action) { + private CompletableFuture thread( + Function> action, + Function resultMapper + ) { return discordSRV.discordAPI().mapExceptions(() -> { return action.apply(channel) .submit() - .thenApply(channel -> discordSRV.discordAPI().getThreadChannel(channel)); + .thenApply(result -> discordSRV.discordAPI().getThreadChannel(resultMapper.apply(result))); }); } @@ -116,4 +153,9 @@ public class DiscordForumChannelImpl implements DiscordForumChannel { public DiscordChannelType getType() { return DiscordChannelType.FORUM; } + + @Override + public String toString() { + return "Forum:" + getName() + "(" + Long.toUnsignedString(getId()) + ")"; + } } diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordNewsChannelImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordNewsChannelImpl.java index 6ab31506..6523797a 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordNewsChannelImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordNewsChannelImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordStageChannelImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordStageChannelImpl.java index 2a0f8bcb..4072300e 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordStageChannelImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordStageChannelImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordTextChannelImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordTextChannelImpl.java index 152162c9..86c7d15a 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordTextChannelImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordTextChannelImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordThreadChannelImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordThreadChannelImpl.java index 6fcc6bc0..6a22963f 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordThreadChannelImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordThreadChannelImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordVoiceChannelImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordVoiceChannelImpl.java index c435e6c0..dbb00fc5 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordVoiceChannelImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/channel/DiscordVoiceChannelImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/component/DiscordInteractionHookImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/component/DiscordInteractionHookImpl.java index df4b74d6..2e7caf4d 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/component/DiscordInteractionHookImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/component/DiscordInteractionHookImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordCustomEmojiImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordCustomEmojiImpl.java index c44c1d06..753a8310 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordCustomEmojiImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordCustomEmojiImpl.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.discord.api.entity.guild; import com.discordsrv.api.discord.entity.guild.DiscordCustomEmoji; diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordGuildImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordGuildImpl.java index 8415c184..98c2e17d 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordGuildImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordGuildImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordGuildMemberImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordGuildMemberImpl.java index e14e2973..3ed2264e 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordGuildMemberImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordGuildMemberImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordRoleImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordRoleImpl.java index 8392e61b..f10e1034 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordRoleImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/guild/DiscordRoleImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/message/ReceivedDiscordMessageClusterImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/message/ReceivedDiscordMessageClusterImpl.java index bace4108..15b1c4c5 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/message/ReceivedDiscordMessageClusterImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/message/ReceivedDiscordMessageClusterImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/message/ReceivedDiscordMessageImpl.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/message/ReceivedDiscordMessageImpl.java index 80802eda..a7df7347 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/message/ReceivedDiscordMessageImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/message/ReceivedDiscordMessageImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/api/entity/message/util/SendableDiscordMessageUtil.java b/common/src/main/java/com/discordsrv/common/discord/api/entity/message/util/SendableDiscordMessageUtil.java index 98215748..5d348151 100644 --- a/common/src/main/java/com/discordsrv/common/discord/api/entity/message/util/SendableDiscordMessageUtil.java +++ b/common/src/main/java/com/discordsrv/common/discord/api/entity/message/util/SendableDiscordMessageUtil.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/connection/DiscordConnectionManager.java b/common/src/main/java/com/discordsrv/common/discord/connection/DiscordConnectionManager.java index 18a1009b..356e71e4 100644 --- a/common/src/main/java/com/discordsrv/common/discord/connection/DiscordConnectionManager.java +++ b/common/src/main/java/com/discordsrv/common/discord/connection/DiscordConnectionManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/connection/details/DiscordConnectionDetailsImpl.java b/common/src/main/java/com/discordsrv/common/discord/connection/details/DiscordConnectionDetailsImpl.java index 42f2dcc2..1c2b13c7 100644 --- a/common/src/main/java/com/discordsrv/common/discord/connection/details/DiscordConnectionDetailsImpl.java +++ b/common/src/main/java/com/discordsrv/common/discord/connection/details/DiscordConnectionDetailsImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/connection/jda/JDAConnectionManager.java b/common/src/main/java/com/discordsrv/common/discord/connection/jda/JDAConnectionManager.java index a3328268..f3f39dbf 100644 --- a/common/src/main/java/com/discordsrv/common/discord/connection/jda/JDAConnectionManager.java +++ b/common/src/main/java/com/discordsrv/common/discord/connection/jda/JDAConnectionManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -283,7 +283,7 @@ public class JDAConnectionManager implements DiscordConnectionManager { throw new IllegalStateException("Cannot reconnect, still active"); } - return connectionFuture = CompletableFuture.runAsync(this::connectInternal, discordSRV.scheduler().executor()); + return connectionFuture = discordSRV.scheduler().execute(this::connectInternal); } private void connectInternal() { @@ -416,10 +416,10 @@ public class JDAConnectionManager implements DiscordConnectionManager { @Override public CompletableFuture reconnect() { - return CompletableFuture.runAsync(() -> { + return discordSRV.scheduler().execute(() -> { shutdown().join(); connect().join(); - }, discordSRV.scheduler().executor()); + }); } @Subscribe(priority = EventPriority.LATE) @@ -430,7 +430,7 @@ public class JDAConnectionManager implements DiscordConnectionManager { @Override public CompletableFuture shutdown(long timeoutMillis) { - return CompletableFuture.runAsync(() -> shutdownInternal(timeoutMillis), discordSRV.scheduler().executor()); + return discordSRV.scheduler().execute(() -> shutdownInternal(timeoutMillis)); } @SuppressWarnings("BusyWait") diff --git a/common/src/main/java/com/discordsrv/common/discord/connection/jda/JDAEventManager.java b/common/src/main/java/com/discordsrv/common/discord/connection/jda/JDAEventManager.java index 188eec3d..68db7b58 100644 --- a/common/src/main/java/com/discordsrv/common/discord/connection/jda/JDAEventManager.java +++ b/common/src/main/java/com/discordsrv/common/discord/connection/jda/JDAEventManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/discord/util/DiscordPermissionUtil.java b/common/src/main/java/com/discordsrv/common/discord/util/DiscordPermissionUtil.java new file mode 100644 index 00000000..1882661b --- /dev/null +++ b/common/src/main/java/com/discordsrv/common/discord/util/DiscordPermissionUtil.java @@ -0,0 +1,87 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + +package com.discordsrv.common.discord.util; + +import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; +import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; + +import java.util.Arrays; +import java.util.Collection; +import java.util.EnumSet; +import java.util.stream.Collectors; + +public final class DiscordPermissionUtil { + + private DiscordPermissionUtil() {} + + public static String missingPermissionsString(GuildChannel channel, Permission... permissions) { + return missingPermissionsString(channel, Arrays.asList(permissions)); + } + + public static String missingPermissionsString(GuildChannel channel, Collection permissions) { + if (channel instanceof ThreadChannel) { + channel = ((ThreadChannel) channel).getParentChannel(); + } + EnumSet missingPermissions = getMissingPermissions(channel, permissions); + return createErrorMessage(missingPermissions, "#" + channel.getName()); + } + + public static EnumSet getMissingPermissions(GuildChannel channel, Collection permissions) { + if (channel instanceof ThreadChannel) { + channel = ((ThreadChannel) channel).getParentChannel(); + } + EnumSet missingPermissions = EnumSet.noneOf(Permission.class); + for (Permission permission : permissions) { + if (!channel.getGuild().getSelfMember().hasPermission(channel, permission)) { + missingPermissions.add(permission); + } + } + return missingPermissions; + } + + public static String missingPermissionsString(Guild guild, Permission... permissions) { + return missingPermissionsString(guild, Arrays.asList(permissions)); + } + + public static String missingPermissionsString(Guild guild, Collection permissions) { + EnumSet missingPermissions = getMissingPermissions(guild, permissions); + return createErrorMessage(missingPermissions, guild.getName()); + } + + public static EnumSet getMissingPermissions(Guild guild, Collection permissions) { + EnumSet missingPermissions = EnumSet.noneOf(Permission.class); + for (Permission permission : permissions) { + if (!guild.getSelfMember().hasPermission(permission)) { + missingPermissions.add(permission); + } + } + return missingPermissions; + } + + public static String createErrorMessage(EnumSet permissions, String where) { + if (permissions.isEmpty()) { + return null; + } + + return "the bot is lacking permissions in " + where + ": " + + permissions.stream().map(Permission::getName).collect(Collectors.joining(", ")); + } +} diff --git a/common/src/main/java/com/discordsrv/common/event/bus/EventBusImpl.java b/common/src/main/java/com/discordsrv/common/event/bus/EventBusImpl.java index 28b05c09..955268e9 100644 --- a/common/src/main/java/com/discordsrv/common/event/bus/EventBusImpl.java +++ b/common/src/main/java/com/discordsrv/common/event/bus/EventBusImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -40,10 +40,7 @@ import org.jetbrains.annotations.NotNull; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.function.Function; @@ -78,6 +75,28 @@ public class EventBusImpl implements EventBus { throw new IllegalArgumentException("Listener is already registered"); } + Pair, List> parsed = parseListeners(eventListener); + List suppressedMethods = parsed.getValue(); + List methods = parsed.getKey(); + + if (methods.isEmpty() || !suppressedMethods.isEmpty()) { + IllegalArgumentException exception = new IllegalArgumentException(eventListener.getClass().getName() + + " doesn't have valid listener methods that are annotated with " + Subscribe.class.getName()); + suppressedMethods.forEach(exception::addSuppressed); + throw exception; + } + + listeners.put(eventListener, methods); + allListeners.addAll(methods); + logger.debug("Listener " + eventListener.getClass().getName() + " subscribed"); + } + + @Override + public Collection getListeners(@NotNull Object eventListener) { + return parseListeners(eventListener).getKey(); + } + + private Pair, List> parseListeners(Object eventListener) { Class listenerClass = eventListener.getClass(); List suppressedMethods = new ArrayList<>(); @@ -90,16 +109,7 @@ public class EventBusImpl implements EventBus { } } while ((currentClass = currentClass.getSuperclass()) != null); - if (methods.isEmpty() || !suppressedMethods.isEmpty()) { - IllegalArgumentException exception = new IllegalArgumentException(listenerClass.getName() - + " doesn't have valid listener methods that are annotated with " + Subscribe.class.getName()); - suppressedMethods.forEach(exception::addSuppressed); - throw exception; - } - - listeners.put(eventListener, methods); - allListeners.addAll(methods); - logger.debug("Listener " + eventListener.getClass().getName() + " subscribed"); + return Pair.of(methods, suppressedMethods); } private void checkMethod(Object eventListener, Class listenerClass, Method method, @@ -215,6 +225,9 @@ public class EventBusImpl implements EventBus { if (eventListener.className().startsWith("com.discordsrv")) { logger.error("Failed to pass " + eventClassName + " to " + eventListener, cause); } else { + // Print the listener failing without references to the DiscordSRV event bus + // as it isn't relevant to the exception, and often causes users to suspect DiscordSRV is doing something wrong when it isn't + //noinspection CallToPrintStackTrace e.getCause().printStackTrace(); } TestHelper.fail(cause); diff --git a/common/src/main/java/com/discordsrv/common/event/bus/EventListenerImpl.java b/common/src/main/java/com/discordsrv/common/event/bus/EventListenerImpl.java index a1c810fd..6adc2d4e 100644 --- a/common/src/main/java/com/discordsrv/common/event/bus/EventListenerImpl.java +++ b/common/src/main/java/com/discordsrv/common/event/bus/EventListenerImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -53,7 +53,8 @@ public class EventListenerImpl implements EventListener { return listener; } - public Class eventClass() { + @Override + public @NotNull Class eventClass() { return eventClass; } diff --git a/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordChatInputInteractionEventImpl.java b/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordChatInputInteractionEventImpl.java index 694d7177..b81d8473 100644 --- a/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordChatInputInteractionEventImpl.java +++ b/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordChatInputInteractionEventImpl.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.DiscordUser; diff --git a/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordMessageContextInteractionEventImpl.java b/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordMessageContextInteractionEventImpl.java index 1a0c21db..ada00074 100644 --- a/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordMessageContextInteractionEventImpl.java +++ b/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordMessageContextInteractionEventImpl.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.DiscordUser; diff --git a/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordUserContextInteractionEventImpl.java b/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordUserContextInteractionEventImpl.java index 408eb262..5e6db7ac 100644 --- a/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordUserContextInteractionEventImpl.java +++ b/common/src/main/java/com/discordsrv/common/event/events/discord/interaction/command/DiscordUserContextInteractionEventImpl.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.event.events.discord.interaction.command; import com.discordsrv.api.discord.entity.DiscordUser; diff --git a/common/src/main/java/com/discordsrv/common/event/events/player/PlayerConnectedEvent.java b/common/src/main/java/com/discordsrv/common/event/events/player/PlayerConnectedEvent.java index c953a7b8..50261e60 100644 --- a/common/src/main/java/com/discordsrv/common/event/events/player/PlayerConnectedEvent.java +++ b/common/src/main/java/com/discordsrv/common/event/events/player/PlayerConnectedEvent.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/event/events/player/PlayerDisconnectedEvent.java b/common/src/main/java/com/discordsrv/common/event/events/player/PlayerDisconnectedEvent.java index 3f3d7408..829f4ba1 100644 --- a/common/src/main/java/com/discordsrv/common/event/events/player/PlayerDisconnectedEvent.java +++ b/common/src/main/java/com/discordsrv/common/event/events/player/PlayerDisconnectedEvent.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/event/util/EventUtil.java b/common/src/main/java/com/discordsrv/common/event/util/EventUtil.java index a59c9b06..cda9db1e 100644 --- a/common/src/main/java/com/discordsrv/common/event/util/EventUtil.java +++ b/common/src/main/java/com/discordsrv/common/event/util/EventUtil.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/exception/ConfigException.java b/common/src/main/java/com/discordsrv/common/exception/ConfigException.java index aa12e2d4..b416bb3a 100644 --- a/common/src/main/java/com/discordsrv/common/exception/ConfigException.java +++ b/common/src/main/java/com/discordsrv/common/exception/ConfigException.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/exception/InvalidListenerMethodException.java b/common/src/main/java/com/discordsrv/common/exception/InvalidListenerMethodException.java index 2ba19679..89480eb8 100644 --- a/common/src/main/java/com/discordsrv/common/exception/InvalidListenerMethodException.java +++ b/common/src/main/java/com/discordsrv/common/exception/InvalidListenerMethodException.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/exception/MessageException.java b/common/src/main/java/com/discordsrv/common/exception/MessageException.java index d8b4eab9..808f94d6 100644 --- a/common/src/main/java/com/discordsrv/common/exception/MessageException.java +++ b/common/src/main/java/com/discordsrv/common/exception/MessageException.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/exception/StorageException.java b/common/src/main/java/com/discordsrv/common/exception/StorageException.java index ca80543e..9bf36ffc 100644 --- a/common/src/main/java/com/discordsrv/common/exception/StorageException.java +++ b/common/src/main/java/com/discordsrv/common/exception/StorageException.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/exception/util/ExceptionUtil.java b/common/src/main/java/com/discordsrv/common/exception/util/ExceptionUtil.java index 2c38f692..add95ff4 100644 --- a/common/src/main/java/com/discordsrv/common/exception/util/ExceptionUtil.java +++ b/common/src/main/java/com/discordsrv/common/exception/util/ExceptionUtil.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/function/CheckedConsumer.java b/common/src/main/java/com/discordsrv/common/function/CheckedConsumer.java index 318a2e3e..96f5d0ef 100644 --- a/common/src/main/java/com/discordsrv/common/function/CheckedConsumer.java +++ b/common/src/main/java/com/discordsrv/common/function/CheckedConsumer.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/function/CheckedFunction.java b/common/src/main/java/com/discordsrv/common/function/CheckedFunction.java index 046713a7..05d75516 100644 --- a/common/src/main/java/com/discordsrv/common/function/CheckedFunction.java +++ b/common/src/main/java/com/discordsrv/common/function/CheckedFunction.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/function/CheckedRunnable.java b/common/src/main/java/com/discordsrv/common/function/CheckedRunnable.java index 49c06698..fa39e53b 100644 --- a/common/src/main/java/com/discordsrv/common/function/CheckedRunnable.java +++ b/common/src/main/java/com/discordsrv/common/function/CheckedRunnable.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -19,7 +19,7 @@ package com.discordsrv.common.function; @FunctionalInterface -public interface CheckedRunnable { +public interface CheckedRunnable { - T run() throws Throwable; + void run() throws Throwable; } diff --git a/common/src/main/java/com/discordsrv/common/function/CheckedSupplier.java b/common/src/main/java/com/discordsrv/common/function/CheckedSupplier.java index f29afdad..6e9c83e7 100644 --- a/common/src/main/java/com/discordsrv/common/function/CheckedSupplier.java +++ b/common/src/main/java/com/discordsrv/common/function/CheckedSupplier.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/future/util/CompletableFutureUtil.java b/common/src/main/java/com/discordsrv/common/future/util/CompletableFutureUtil.java index 0795d9ce..ea7d8a15 100644 --- a/common/src/main/java/com/discordsrv/common/future/util/CompletableFutureUtil.java +++ b/common/src/main/java/com/discordsrv/common/future/util/CompletableFutureUtil.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -19,12 +19,15 @@ package com.discordsrv.common.future.util; import com.discordsrv.common.DiscordSRV; +import com.discordsrv.common.function.CheckedRunnable; +import com.discordsrv.common.function.CheckedSupplier; import java.time.Duration; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeoutException; @@ -53,20 +56,13 @@ public final class CompletableFutureUtil { @SafeVarargs public static CompletableFuture> combine(CompletableFuture... futures) { - CompletableFuture> future = new CompletableFuture<>(); - CompletableFuture.allOf(futures).whenComplete((v, t) -> { - if (t != null) { - future.completeExceptionally(t); - return; - } - + return CompletableFuture.allOf(futures).thenApply(v -> { List results = new ArrayList<>(); for (CompletableFuture aFuture : futures) { results.add(aFuture.join()); } - future.complete(results); + return results; }); - return future; } public static CompletableFuture timeout(DiscordSRV discordSRV, CompletableFuture future, Duration timeout) { @@ -81,4 +77,28 @@ public final class CompletableFutureUtil { } }); } + + public static CompletableFuture supplyAsync(CheckedSupplier supplier, Executor executor) { + CompletableFuture future = new CompletableFuture<>(); + executor.execute(() -> { + if (future.isCancelled()) { + return; + } + try { + future.complete(supplier.get()); + } catch (InterruptedException ignored) { + Thread.currentThread().interrupt(); + } catch (Throwable t) { + future.completeExceptionally(t); + } + }); + return future; + } + + public static CompletableFuture runAsync(CheckedRunnable runnable, Executor executor) { + return supplyAsync(() -> { + runnable.run(); + return null; + }, executor); + } } diff --git a/common/src/main/java/com/discordsrv/common/groupsync/GroupSyncModule.java b/common/src/main/java/com/discordsrv/common/groupsync/GroupSyncModule.java index 962f14ba..214f8989 100644 --- a/common/src/main/java/com/discordsrv/common/groupsync/GroupSyncModule.java +++ b/common/src/main/java/com/discordsrv/common/groupsync/GroupSyncModule.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.groupsync; import com.discordsrv.api.discord.entity.guild.DiscordRole; diff --git a/common/src/main/java/com/discordsrv/common/groupsync/SynchronizationSummary.java b/common/src/main/java/com/discordsrv/common/groupsync/SynchronizationSummary.java new file mode 100644 index 00000000..e69de29b diff --git a/common/src/main/java/com/discordsrv/common/groupsync/enums/GroupSyncCause.java b/common/src/main/java/com/discordsrv/common/groupsync/enums/GroupSyncCause.java index 88481545..1fca04d0 100644 --- a/common/src/main/java/com/discordsrv/common/groupsync/enums/GroupSyncCause.java +++ b/common/src/main/java/com/discordsrv/common/groupsync/enums/GroupSyncCause.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/groupsync/enums/GroupSyncResult.java b/common/src/main/java/com/discordsrv/common/groupsync/enums/GroupSyncResult.java index e3ed05db..1bcdfcda 100644 --- a/common/src/main/java/com/discordsrv/common/groupsync/enums/GroupSyncResult.java +++ b/common/src/main/java/com/discordsrv/common/groupsync/enums/GroupSyncResult.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/http/util/HttpUtil.java b/common/src/main/java/com/discordsrv/common/http/util/HttpUtil.java index 1565abf0..1ff7258d 100644 --- a/common/src/main/java/com/discordsrv/common/http/util/HttpUtil.java +++ b/common/src/main/java/com/discordsrv/common/http/util/HttpUtil.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.http.util; import com.discordsrv.common.DiscordSRV; @@ -26,8 +44,7 @@ public final class HttpUtil { } public static CompletableFuture readJson(DiscordSRV discordSRV, Request request, Class type) { - CompletableFuture future = new CompletableFuture<>(); - discordSRV.scheduler().run(() -> { + return discordSRV.scheduler().supply(() -> { try (Response response = discordSRV.httpClient().newCall(request).execute()) { ResponseBody responseBody = checkIfResponseSuccessful(request, response); @@ -35,11 +52,8 @@ public final class HttpUtil { if (result == null) { throw new MessageException("Response json cannot be parsed"); } - future.complete(result); - } catch (Throwable t) { - future.completeExceptionally(t); + return result; } }); - return future; } } diff --git a/common/src/main/java/com/discordsrv/common/integration/LuckPermsIntegration.java b/common/src/main/java/com/discordsrv/common/integration/LuckPermsIntegration.java index 794513a0..9a0f7ac9 100644 --- a/common/src/main/java/com/discordsrv/common/integration/LuckPermsIntegration.java +++ b/common/src/main/java/com/discordsrv/common/integration/LuckPermsIntegration.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/invite/DiscordInviteModule.java b/common/src/main/java/com/discordsrv/common/invite/DiscordInviteModule.java index 7b8fd256..0681f188 100644 --- a/common/src/main/java/com/discordsrv/common/invite/DiscordInviteModule.java +++ b/common/src/main/java/com/discordsrv/common/invite/DiscordInviteModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -26,29 +26,33 @@ import com.discordsrv.api.placeholder.FormattedText; import com.discordsrv.api.placeholder.annotation.Placeholder; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.config.main.DiscordInviteConfig; +import com.discordsrv.common.discord.util.DiscordPermissionUtil; +import com.discordsrv.common.logging.NamedLogger; import com.discordsrv.common.module.type.AbstractModule; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.Invite; +import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.channel.attribute.IInviteContainer; import net.dv8tion.jda.api.events.guild.invite.GuildInviteDeleteEvent; import net.dv8tion.jda.api.events.guild.update.GuildUpdateVanityCodeEvent; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; -import java.util.Collection; -import java.util.Collections; -import java.util.List; +import java.util.*; +import java.util.concurrent.Future; import java.util.function.Consumer; public class DiscordInviteModule extends AbstractModule { - private static final String UNKNOWN_INVITE = "https://discord.gg/#Could_not_get_invite,_please_check_your_configuration"; + private static final String UNKNOWN_INVITE = DiscordSRV.WEBSITE + "/invalid-invite"; private String invite; + private Boolean botPublic = null; + private Future appInfoFuture = null; public DiscordInviteModule(DiscordSRV discordSRV) { - super(discordSRV); + super(discordSRV, new NamedLogger(discordSRV, "INVITE")); discordSRV.placeholderService().addGlobalContext(this); } @@ -56,10 +60,10 @@ public class DiscordInviteModule extends AbstractModule { public @NotNull Collection requiredIntents() { DiscordInviteConfig config = discordSRV.config().invite; if (StringUtils.isNotEmpty(config.inviteUrl)) { - return Collections.emptyList(); + return Collections.emptySet(); } - return Collections.singleton(DiscordGatewayIntent.GUILD_INVITES); + return EnumSet.of(DiscordGatewayIntent.GUILD_INVITES); } @Subscribe @@ -78,6 +82,7 @@ public class DiscordInviteModule extends AbstractModule { public void reload(Consumer resultConsumer) { JDA jda = discordSRV.jda(); if (jda == null) { + logger().debug("JDA == null"); return; } @@ -86,21 +91,47 @@ public class DiscordInviteModule extends AbstractModule { // Manual String invite = config.inviteUrl; if (StringUtils.isNotEmpty(invite)) { + logger().debug("Using configured invite"); this.invite = invite; return; } + Guild guild = jda.getGuildById(config.serverId); + if (guild != null) { + logger().debug("Automatically determining invite for configured server id (" + Long.toUnsignedString(config.serverId) + ")"); + consumeGuild(guild, config); + return; + } + List guilds = jda.getGuilds(); if (guilds.size() != 1) { + logger().debug("Bot is in " + guilds.size() + " servers, not automatically determining invites"); return; } - Guild guild = guilds.get(0); + if (botPublic == null) { + if (appInfoFuture == null) { + appInfoFuture = jda.retrieveApplicationInfo().submit().whenComplete((appInfo, t) -> { + botPublic = appInfo.isBotPublic(); + logger().debug("The bot is " + (botPublic ? "public" : "private")); + appInfoFuture = null; + consumeGuild(guilds.get(0), config); + }); + } + return; + } + if (!botPublic) { + consumeGuild(guilds.get(0), config); + } + } + + private void consumeGuild(Guild guild, DiscordInviteConfig config) { // Vanity url if (config.attemptToUseVanityUrl) { String vanityUrl = guild.getVanityUrl(); if (vanityUrl != null) { + logger().debug("Using vanity url"); this.invite = vanityUrl; return; } @@ -108,23 +139,59 @@ public class DiscordInviteModule extends AbstractModule { // Auto create if (config.autoCreateInvite) { - Member selfMember = guild.getSelfMember(); - if (!selfMember.hasPermission(Permission.CREATE_INSTANT_INVITE)) { + logger().debug("Auto creating invite"); + + List channels = new ArrayList<>(); + Optional.ofNullable(guild.getRulesChannel()).ifPresent(channels::add); + Optional.ofNullable(guild.getDefaultChannel()).ifPresent(channels::add); + if (channels.isEmpty()) { + logger().debug("No rules and default channel"); return; } - IInviteContainer channel = guild.getRulesChannel(); - if (channel == null) { - channel = guild.getDefaultChannel(); + List missingPermissionMessages = new ArrayList<>(); + IInviteContainer channelToUse = null; + for (IInviteContainer potentialChannel : channels) { + String missingPermissions = DiscordPermissionUtil.missingPermissionsString( + potentialChannel, + Permission.VIEW_CHANNEL, + Permission.CREATE_INSTANT_INVITE, + Permission.MANAGE_CHANNEL + ); + + if (missingPermissions != null) { + missingPermissionMessages.add(missingPermissions); + } else { + channelToUse = potentialChannel; + break; + } } - if (channel == null) { + if (channelToUse == null) { + logger().error("Failed to automatically create invite: " + String.join(" and ", missingPermissionMessages)); return; } - channel.createInvite().setMaxAge(0).setUnique(true).queue( - inv -> this.invite = inv.getUrl(), - ErrorCallbackContext.context("Failed to auto create invite") - ); + IInviteContainer channel = channelToUse; + channel.retrieveInvites().queue(invites -> { + boolean found = false; + for (Invite existingInvite : invites) { + User inviter = existingInvite.getInviter(); + if (inviter != null && inviter.getIdLong() == inviter.getJDA().getSelfUser().getIdLong()) { + this.invite = existingInvite.getUrl(); + found = true; + break; + } + } + + if (found) { + return; + } + + channel.createInvite().setMaxAge(0).setUnique(true).queue( + inv -> this.invite = inv.getUrl(), + ErrorCallbackContext.context("Failed to auto create invite") + ); + }, ErrorCallbackContext.context("Failed to get invites for automatic invite creation")); } } diff --git a/common/src/main/java/com/discordsrv/common/linking/LinkProvider.java b/common/src/main/java/com/discordsrv/common/linking/LinkProvider.java index f8fbb423..9d93026a 100644 --- a/common/src/main/java/com/discordsrv/common/linking/LinkProvider.java +++ b/common/src/main/java/com/discordsrv/common/linking/LinkProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/linking/LinkStore.java b/common/src/main/java/com/discordsrv/common/linking/LinkStore.java index bfa4f280..85d010a2 100644 --- a/common/src/main/java/com/discordsrv/common/linking/LinkStore.java +++ b/common/src/main/java/com/discordsrv/common/linking/LinkStore.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/linking/LinkingModule.java b/common/src/main/java/com/discordsrv/common/linking/LinkingModule.java index 75e0e867..7bc3274d 100644 --- a/common/src/main/java/com/discordsrv/common/linking/LinkingModule.java +++ b/common/src/main/java/com/discordsrv/common/linking/LinkingModule.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.linking; import com.discordsrv.api.event.events.linking.AccountLinkedEvent; diff --git a/common/src/main/java/com/discordsrv/common/linking/impl/CachedLinkProvider.java b/common/src/main/java/com/discordsrv/common/linking/impl/CachedLinkProvider.java index 58631911..fe97b45e 100644 --- a/common/src/main/java/com/discordsrv/common/linking/impl/CachedLinkProvider.java +++ b/common/src/main/java/com/discordsrv/common/linking/impl/CachedLinkProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/linking/impl/MinecraftAuthenticationLinker.java b/common/src/main/java/com/discordsrv/common/linking/impl/MinecraftAuthenticationLinker.java index c42beb44..f4995cca 100644 --- a/common/src/main/java/com/discordsrv/common/linking/impl/MinecraftAuthenticationLinker.java +++ b/common/src/main/java/com/discordsrv/common/linking/impl/MinecraftAuthenticationLinker.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -171,15 +171,7 @@ public class MinecraftAuthenticationLinker extends CachedLinkProvider implements Consumer linked, Consumer unlinked ) { - CompletableFuture> authService = new CompletableFuture<>(); - - discordSRV.scheduler().run(() -> { - try { - authService.complete(authSupplier.get()); - } catch (Throwable t) { - authService.completeExceptionally(t); - } - }); + CompletableFuture> authService = discordSRV.scheduler().supply(authSupplier); if (!canCauseLink) { return authService; } diff --git a/common/src/main/java/com/discordsrv/common/linking/impl/StorageLinker.java b/common/src/main/java/com/discordsrv/common/linking/impl/StorageLinker.java index 95739cb6..fcf1620c 100644 --- a/common/src/main/java/com/discordsrv/common/linking/impl/StorageLinker.java +++ b/common/src/main/java/com/discordsrv/common/linking/impl/StorageLinker.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -41,89 +41,68 @@ public class StorageLinker extends CachedLinkProvider implements LinkProvider, L @Override public CompletableFuture> queryUserId(@NotNull UUID playerUUID, boolean canCauseLink) { - return CompletableFuture.supplyAsync(() -> { + return discordSRV.scheduler().supply(() -> { Long value = discordSRV.storage().getUserId(playerUUID); return Optional.ofNullable(value); - }, discordSRV.scheduler().executor()); + }); } @Override public CompletableFuture> queryPlayerUUID(long userId, boolean canCauseLink) { - return CompletableFuture.supplyAsync(() -> { + return discordSRV.scheduler().supply(() -> { UUID value = discordSRV.storage().getPlayerUUID(userId); return Optional.ofNullable(value); - }, discordSRV.scheduler().executor()); + }); } @Override public CompletableFuture createLink(@NotNull UUID playerUUID, long userId) { - return CompletableFuture.runAsync( - () -> discordSRV.storage().createLink(playerUUID, userId), - discordSRV.scheduler().executor() - ); + return discordSRV.scheduler().execute(() -> discordSRV.storage().createLink(playerUUID, userId)); } @Override public CompletableFuture removeLink(@NotNull UUID playerUUID, long userId) { - return CompletableFuture.runAsync( - () -> discordSRV.storage().removeLink(playerUUID, userId), - discordSRV.scheduler().executor() - ); + return discordSRV.scheduler().execute(() -> discordSRV.storage().removeLink(playerUUID, userId)); } @Override public CompletableFuture getCodeLinking(long userId, @NotNull String code) { - return CompletableFuture.supplyAsync( - () -> discordSRV.storage().getLinkingCode(code), - discordSRV.scheduler().executor() - ); + return discordSRV.scheduler().supply(() -> discordSRV.storage().getLinkingCode(code)); } @Override public CompletableFuture removeLinkingCode(@NotNull String code) { - return CompletableFuture.runAsync( - () -> { - UUID player = discordSRV.storage().getLinkingCode(code); - discordSRV.storage().removeLinkingCode(player); - }, - discordSRV.scheduler().executor() - ); + return discordSRV.scheduler().execute(() -> { + UUID player = discordSRV.storage().getLinkingCode(code); + discordSRV.storage().removeLinkingCode(player); + }); } @Override public CompletableFuture removeLinkingCode(@NotNull UUID playerUUID) { - return CompletableFuture.runAsync( - () -> discordSRV.storage().removeLinkingCode(playerUUID), - discordSRV.scheduler().executor() - ); + return discordSRV.scheduler().execute(() -> discordSRV.storage().removeLinkingCode(playerUUID)); } @Override public CompletableFuture getLinkedAccountCount() { - return CompletableFuture.supplyAsync( - () -> discordSRV.storage().getLinkedAccountCount(), - discordSRV.scheduler().executor() - ); + return discordSRV.scheduler().supply(() -> discordSRV.storage().getLinkedAccountCount()); } private final SecureRandom secureRandom = new SecureRandom(); @Override public CompletableFuture getLinkingInstructions(String username, UUID playerUUID, @Nullable Locale locale, @Nullable String requestReason) { - return CompletableFuture.supplyAsync( - () -> { - String code = null; - while (code == null || discordSRV.storage().getLinkingCode(code) != null) { - code = String.valueOf(secureRandom.nextInt(1000000)); - while (code.length() != 6) { - code = "0" + code; - } - } + return discordSRV.scheduler().supply(() -> { + String code = null; + while (code == null || discordSRV.storage().getLinkingCode(code) != null) { + code = String.valueOf(secureRandom.nextInt(1000000)); + while (code.length() != 6) { + code = "0" + code; + } + } - discordSRV.storage().storeLinkingCode(playerUUID, code); - return ComponentUtil.toAPI(Component.text(code)); - }, - discordSRV.scheduler().executor() - ); + discordSRV.storage().storeLinkingCode(playerUUID, code); + return ComponentUtil.toAPI(Component.text(code)); + }); } } diff --git a/common/src/main/java/com/discordsrv/common/linking/requirelinking/RequiredLinkingModule.java b/common/src/main/java/com/discordsrv/common/linking/requirelinking/RequiredLinkingModule.java index aa894ad0..4cf78aae 100644 --- a/common/src/main/java/com/discordsrv/common/linking/requirelinking/RequiredLinkingModule.java +++ b/common/src/main/java/com/discordsrv/common/linking/requirelinking/RequiredLinkingModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/linking/requirelinking/ServerRequireLinkingModule.java b/common/src/main/java/com/discordsrv/common/linking/requirelinking/ServerRequireLinkingModule.java index 3154bea3..4d0f5a73 100644 --- a/common/src/main/java/com/discordsrv/common/linking/requirelinking/ServerRequireLinkingModule.java +++ b/common/src/main/java/com/discordsrv/common/linking/requirelinking/ServerRequireLinkingModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/DiscordBoostingRequirement.java b/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/DiscordBoostingRequirement.java index 5e8c3d90..73704c27 100644 --- a/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/DiscordBoostingRequirement.java +++ b/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/DiscordBoostingRequirement.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/DiscordRoleRequirement.java b/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/DiscordRoleRequirement.java index 091984d4..92302e77 100644 --- a/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/DiscordRoleRequirement.java +++ b/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/DiscordRoleRequirement.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/DiscordServerRequirement.java b/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/DiscordServerRequirement.java index f926245b..5579b6cd 100644 --- a/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/DiscordServerRequirement.java +++ b/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/DiscordServerRequirement.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/LongRequirement.java b/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/LongRequirement.java index ad13067b..6b376f04 100644 --- a/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/LongRequirement.java +++ b/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/LongRequirement.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/MinecraftAuthRequirement.java b/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/MinecraftAuthRequirement.java index a6aa7f59..c1bdb70a 100644 --- a/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/MinecraftAuthRequirement.java +++ b/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/MinecraftAuthRequirement.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -19,7 +19,6 @@ package com.discordsrv.common.linking.requirelinking.requirement; import com.discordsrv.common.DiscordSRV; -import com.discordsrv.common.function.CheckedSupplier; import me.minecraftauth.lib.AuthService; import me.minecraftauth.lib.account.platform.twitch.SubTier; import me.minecraftauth.lib.exception.LookupException; @@ -165,23 +164,13 @@ public class MinecraftAuthRequirement implements Requirement isMet(Reference atomicReference, UUID player, long userId) { String token = discordSRV.connectionConfig().minecraftAuth.token; T value = atomicReference.getValue(); - if (value == null) { - return supply(() -> test.test(token, player)); - } else { - return supply(() -> testSpecific.test(token, player, value)); - } - } - - private CompletableFuture supply(CheckedSupplier provider) { - CompletableFuture completableFuture = new CompletableFuture<>(); - discordSRV.scheduler().run(() -> { - try { - completableFuture.complete(provider.get()); - } catch (Throwable t) { - completableFuture.completeExceptionally(t); + return discordSRV.scheduler().supply(() -> { + if (value == null) { + return test.test(token, player); + } else { + return testSpecific.test(token, player, value); } }); - return completableFuture; } @FunctionalInterface diff --git a/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/Requirement.java b/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/Requirement.java index 66d7116b..681863c4 100644 --- a/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/Requirement.java +++ b/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/Requirement.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/parser/RequirementParser.java b/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/parser/RequirementParser.java index ac717955..8fe072b6 100644 --- a/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/parser/RequirementParser.java +++ b/common/src/main/java/com/discordsrv/common/linking/requirelinking/requirement/parser/RequirementParser.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/logging/Logger.java b/common/src/main/java/com/discordsrv/common/logging/Logger.java index 2d75e27e..487e76b7 100644 --- a/common/src/main/java/com/discordsrv/common/logging/Logger.java +++ b/common/src/main/java/com/discordsrv/common/logging/Logger.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/logging/NamedLogger.java b/common/src/main/java/com/discordsrv/common/logging/NamedLogger.java index fb5f986e..30ac4d14 100644 --- a/common/src/main/java/com/discordsrv/common/logging/NamedLogger.java +++ b/common/src/main/java/com/discordsrv/common/logging/NamedLogger.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/logging/backend/LogFilter.java b/common/src/main/java/com/discordsrv/common/logging/backend/LogFilter.java index a526650e..63da6a35 100644 --- a/common/src/main/java/com/discordsrv/common/logging/backend/LogFilter.java +++ b/common/src/main/java/com/discordsrv/common/logging/backend/LogFilter.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/logging/backend/LoggingBackend.java b/common/src/main/java/com/discordsrv/common/logging/backend/LoggingBackend.java index f5c095f1..8a26edc2 100644 --- a/common/src/main/java/com/discordsrv/common/logging/backend/LoggingBackend.java +++ b/common/src/main/java/com/discordsrv/common/logging/backend/LoggingBackend.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/logging/backend/impl/JavaLoggerImpl.java b/common/src/main/java/com/discordsrv/common/logging/backend/impl/JavaLoggerImpl.java index 289b6527..e87b96c9 100644 --- a/common/src/main/java/com/discordsrv/common/logging/backend/impl/JavaLoggerImpl.java +++ b/common/src/main/java/com/discordsrv/common/logging/backend/impl/JavaLoggerImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/logging/backend/impl/Log4JLoggerImpl.java b/common/src/main/java/com/discordsrv/common/logging/backend/impl/Log4JLoggerImpl.java index 419867fe..806d2795 100644 --- a/common/src/main/java/com/discordsrv/common/logging/backend/impl/Log4JLoggerImpl.java +++ b/common/src/main/java/com/discordsrv/common/logging/backend/impl/Log4JLoggerImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/logging/backend/impl/SLF4JLoggerImpl.java b/common/src/main/java/com/discordsrv/common/logging/backend/impl/SLF4JLoggerImpl.java index 895c5d36..2a0b1116 100644 --- a/common/src/main/java/com/discordsrv/common/logging/backend/impl/SLF4JLoggerImpl.java +++ b/common/src/main/java/com/discordsrv/common/logging/backend/impl/SLF4JLoggerImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/logging/impl/DependencyLoggingHandler.java b/common/src/main/java/com/discordsrv/common/logging/impl/DependencyLoggingHandler.java index d29f24c0..36c5f6c3 100644 --- a/common/src/main/java/com/discordsrv/common/logging/impl/DependencyLoggingHandler.java +++ b/common/src/main/java/com/discordsrv/common/logging/impl/DependencyLoggingHandler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -42,7 +42,9 @@ public class DependencyLoggingHandler implements LogAppender { "WebSocket connection was closed and cannot be recovered due to identification issues", // Failed JDA requests (handled with RestAction default failure) "There was an I/O error while executing a REST request: ", - "There was an unexpected error while executing a REST request" + "There was an unexpected error while executing a REST request", + // This doesn't need to be a warning logged to the user + "Encountered 429 on route " )); BLACKLISTED_MESSAGES.put("com.zaxxer.hikari", Collections.singletonList( // This is fine, we don't need a warning about it @@ -76,7 +78,8 @@ public class DependencyLoggingHandler implements LogAppender { // Go through the blacklisted messages we gathered for (String blacklistedMessage : blacklistedMessages) { if (message.contains(blacklistedMessage)) { - return; + logLevel = LogLevel.DEBUG; + break; } } } diff --git a/common/src/main/java/com/discordsrv/common/logging/impl/DiscordSRVLogger.java b/common/src/main/java/com/discordsrv/common/logging/impl/DiscordSRVLogger.java index 011d5ee3..1726c5c4 100644 --- a/common/src/main/java/com/discordsrv/common/logging/impl/DiscordSRVLogger.java +++ b/common/src/main/java/com/discordsrv/common/logging/impl/DiscordSRVLogger.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -21,9 +21,13 @@ package com.discordsrv.common.logging.impl; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.config.main.DebugConfig; import com.discordsrv.common.config.main.MainConfig; +import com.discordsrv.common.discord.util.DiscordPermissionUtil; import com.discordsrv.common.logging.LogLevel; import com.discordsrv.common.logging.Logger; +import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; import net.dv8tion.jda.api.exceptions.InsufficientPermissionException; import org.apache.commons.lang3.exception.ExceptionUtils; import org.jetbrains.annotations.NotNull; @@ -38,10 +42,7 @@ import java.nio.file.StandardOpenOption; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.Duration; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Queue; +import java.util.*; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.Future; @@ -125,8 +126,27 @@ public class DiscordSRVLogger implements Logger { throwable = null; } if (throwable instanceof InsufficientPermissionException) { - Permission permission = ((InsufficientPermissionException) throwable).getPermission(); - String msg = "The bot is missing the \"" + permission.getName() + "\" permission"; + InsufficientPermissionException exception = (InsufficientPermissionException) throwable; + Permission permission = exception.getPermission(); + + JDA jda = discordSRV.jda(); + GuildChannel guildChannel = jda != null ? exception.getChannel(jda) : null; + long channelId = exception.getChannelId(); + Guild guild = jda != null ? exception.getGuild(jda) : null; + long guildId = exception.getGuildId(); + + String where; + if (guildChannel != null) { + where = "#" + guildChannel.getName(); + } else if (channelId != 0) { + where = "Channel ID " + Long.toUnsignedString(channelId); + } else if (guild != null) { + where = guild.getName(); + } else { + where = "Server ID " + Long.toUnsignedString(guildId); + } + + String msg = DiscordPermissionUtil.createErrorMessage(EnumSet.of(permission), where); if (message == null) { message = msg; } else { diff --git a/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordChatMessageModule.java b/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordChatMessageModule.java index 6061dd6c..1d628930 100644 --- a/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordChatMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordChatMessageModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -49,8 +49,8 @@ import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import java.time.Duration; -import java.util.Arrays; import java.util.Collection; +import java.util.EnumSet; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; @@ -92,7 +92,7 @@ public class DiscordChatMessageModule extends AbstractModule { @Override public @NotNull Collection requiredIntents() { - return Arrays.asList(DiscordGatewayIntent.GUILD_MESSAGES, DiscordGatewayIntent.MESSAGE_CONTENT); + return EnumSet.of(DiscordGatewayIntent.GUILD_MESSAGES, DiscordGatewayIntent.MESSAGE_CONTENT); } @Subscribe diff --git a/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordMessageMirroringModule.java b/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordMessageMirroringModule.java index 3188b841..2e58224b 100644 --- a/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordMessageMirroringModule.java +++ b/common/src/main/java/com/discordsrv/common/messageforwarding/discord/DiscordMessageMirroringModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -41,11 +41,14 @@ import com.discordsrv.common.config.main.channels.MirroringConfig; import com.discordsrv.common.config.main.channels.base.BaseChannelConfig; import com.discordsrv.common.config.main.channels.base.IChannelConfig; import com.discordsrv.common.config.main.generic.DiscordIgnoresConfig; +import com.discordsrv.common.discord.util.DiscordPermissionUtil; import com.discordsrv.common.future.util.CompletableFutureUtil; import com.discordsrv.common.logging.NamedLogger; import com.discordsrv.common.module.type.AbstractModule; import com.github.benmanes.caffeine.cache.Cache; +import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel; import okhttp3.Request; import okhttp3.Response; import okhttp3.ResponseBody; @@ -57,6 +60,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; import java.util.concurrent.TimeUnit; public class DiscordMessageMirroringModule extends AbstractModule { @@ -83,7 +87,7 @@ public class DiscordMessageMirroringModule extends AbstractModule { @Override public @NotNull Collection requiredIntents() { - return Arrays.asList(DiscordGatewayIntent.GUILD_MESSAGES, DiscordGatewayIntent.MESSAGE_CONTENT); + return EnumSet.of(DiscordGatewayIntent.GUILD_MESSAGES, DiscordGatewayIntent.MESSAGE_CONTENT); } @SuppressWarnings("unchecked") // Wacky generics @@ -160,7 +164,7 @@ public class DiscordMessageMirroringModule extends AbstractModule { } futures.add( - discordSRV.discordAPI().findOrCreateDestinations(channelConfig, true, true) + discordSRV.destinations().lookupDestination(channelConfig.destination(), true, true) .thenApply(messageChannels -> { List targets = new ArrayList<>(); for (DiscordGuildMessageChannel messageChannel : messageChannels) { @@ -171,7 +175,7 @@ public class DiscordMessageMirroringModule extends AbstractModule { ); } - CompletableFutureUtil.combine(futures).whenComplete((lists, t) -> { + CompletableFutureUtil.combine(futures).whenComplete((lists, v) -> { Set channelIdsHandled = new HashSet<>(); for (MirrorOperation operation : lists) { List> mirrorFutures = new ArrayList<>(); @@ -214,13 +218,23 @@ public class DiscordMessageMirroringModule extends AbstractModule { return; } + GuildMessageChannel channel = (GuildMessageChannel) mirrorChannel.getAsJDAMessageChannel(); + String missingPermissions = DiscordPermissionUtil.missingPermissionsString(channel, Permission.VIEW_CHANNEL, Permission.MANAGE_WEBHOOKS); + if (missingPermissions != null) { + logger().error("Failed to mirror message to " + describeChannel(mirrorChannel) + ": " + missingPermissions); + continue; + } + CompletableFuture future = mirrorChannel.sendMessage(messageBuilder.build()) .thenApply(msg -> new MirroredMessage(msg, config)); mirrorFutures.add(future); - future.exceptionally(t2 -> { - logger().error("Failed to mirror message to " + mirrorChannel, t2); + future.exceptionally(t -> { + if (t instanceof CompletionException) { + t = t.getCause(); + } + logger().error("Failed to mirror message to " + describeChannel(mirrorChannel), t); for (InputStream stream : streams) { try { stream.close(); @@ -243,11 +257,22 @@ public class DiscordMessageMirroringModule extends AbstractModule { }); } }).exceptionally(t -> { + if (t instanceof CompletionException) { + t = t.getCause(); + } logger().error("Failed to mirror message", t); return null; }); } + private String describeChannel(DiscordGuildMessageChannel channel) { + if (channel instanceof DiscordThreadChannel) { + return "\"" + channel.getName() + "\" in #" + ((DiscordThreadChannel) channel).getParentChannel().getName(); + } + + return "#" + channel.getName(); + } + @Subscribe public void onDiscordMessageUpdate(DiscordMessageUpdateEvent event) { Cache syncs = mapping.getIfPresent(event.getChannel().getId()); @@ -289,13 +314,13 @@ public class DiscordMessageMirroringModule extends AbstractModule { } for (MessageReference reference : sync.mirrors) { - DiscordMessageChannel channel = reference.getMessageChannel(discordSRV); + DiscordGuildMessageChannel channel = reference.getMessageChannel(discordSRV); if (channel == null) { continue; } channel.deleteMessageById(reference.messageId, reference.webhookMessage).exceptionally(t -> { - logger().error("Failed to delete mirrored message in " + channel); + logger().error("Failed to delete mirrored message in " + describeChannel(channel)); return null; }); } diff --git a/common/src/main/java/com/discordsrv/common/messageforwarding/game/AbstractGameMessageModule.java b/common/src/main/java/com/discordsrv/common/messageforwarding/game/AbstractGameMessageModule.java index 6d71d2de..2a878c52 100644 --- a/common/src/main/java/com/discordsrv/common/messageforwarding/game/AbstractGameMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/messageforwarding/game/AbstractGameMessageModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -20,7 +20,9 @@ package com.discordsrv.common.messageforwarding.game; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.discord.connection.jda.errorresponse.ErrorCallbackContext; +import com.discordsrv.api.discord.entity.channel.DiscordGuildChannel; import com.discordsrv.api.discord.entity.channel.DiscordGuildMessageChannel; +import com.discordsrv.api.discord.entity.channel.DiscordThreadChannel; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessage; import com.discordsrv.api.discord.entity.message.ReceivedDiscordMessageCluster; import com.discordsrv.api.discord.entity.message.SendableDiscordMessage; @@ -31,18 +33,36 @@ import com.discordsrv.common.config.main.channels.base.BaseChannelConfig; import com.discordsrv.common.config.main.channels.base.IChannelConfig; import com.discordsrv.common.config.main.generic.IMessageConfig; import com.discordsrv.common.discord.api.entity.message.ReceivedDiscordMessageClusterImpl; +import com.discordsrv.common.discord.util.DiscordPermissionUtil; import com.discordsrv.common.future.util.CompletableFutureUtil; import com.discordsrv.common.logging.NamedLogger; import com.discordsrv.common.module.type.AbstractModule; import com.discordsrv.common.player.IPlayer; import com.discordsrv.common.testing.TestHelper; +import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; +import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; +import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionException; +/** + * An abstracted flow to send in-game messages to a given destination and publish the results to the event bus. + *

+ * Order of operations: + * - Event (E generic) is received, implementation calls {@link #process(AbstractGameMessageReceiveEvent, DiscordSRVPlayer, GameChannel)} + * - {@link IPlayer} and {@link BaseChannelConfig} (uses {@link #mapConfig(AbstractGameMessageReceiveEvent, BaseChannelConfig)} are resolved, then {@link #forwardToChannel(AbstractGameMessageReceiveEvent, IPlayer, BaseChannelConfig)} is called + * - Destinations are looked up and {@link #sendMessageToChannels} gets called + * - {@link #setPlaceholders(IMessageConfig, AbstractGameMessageReceiveEvent, SendableDiscordMessage.Formatter)} is called to set any additional placeholders + * - {@link #sendMessageToChannel(DiscordGuildMessageChannel, SendableDiscordMessage)} is called (once per channel) to send messages to individual channels + * - {@link #postClusterToEventBus(ReceivedDiscordMessageCluster)} is called with all messages that were sent (if any messages were sent) + * + * @param config model + * @param the event indicating a message was received from in-game, of type {@link AbstractGameMessageReceiveEvent} + */ public abstract class AbstractGameMessageModule extends AbstractModule { public AbstractGameMessageModule(DiscordSRV discordSRV, String loggerName) { @@ -86,6 +106,10 @@ public abstract class AbstractGameMessageModule { + return discordSRV.destinations().lookupDestination(channelConfig.destination(), true, true).thenCompose(messageChannels -> { SendableDiscordMessage.Builder format = moduleConfig.format(); if (format == null || format.isEmpty()) { return CompletableFuture.completedFuture(null); } - Map, DiscordGuildMessageChannel> messageFutures; - messageFutures = sendMessageToChannels( + List> messageFutures = sendMessageToChannels( moduleConfig, player, format, messageChannels, event, // Context config, player ); - return CompletableFuture.allOf(messageFutures.keySet().toArray(new CompletableFuture[0])) - .whenComplete((vo, t2) -> { - Set messages = new LinkedHashSet<>(); - for (Map.Entry, DiscordGuildMessageChannel> entry : messageFutures.entrySet()) { - CompletableFuture future = entry.getKey(); - if (future.isCompletedExceptionally()) { - future.exceptionally(t -> { - if (t instanceof CompletionException) { - t = t.getCause(); - } - ErrorCallbackContext.context("Failed to deliver a message to " + entry.getValue()).accept(t); - TestHelper.fail(t); - return null; - }); - // Ignore ones that failed - continue; - } + return CompletableFutureUtil.combine(messageFutures).whenComplete((vo, t2) -> { + Set messages = new LinkedHashSet<>(); + for (CompletableFuture future : messageFutures) { + ReceivedDiscordMessage message = future.join(); + if (message != null) { + messages.add(message); + } + } - // They are all done, so joining will return the result instantly - messages.add(future.join()); - } + if (messages.isEmpty()) { + // Nothing was delivered + return; + } - if (messages.isEmpty()) { - // Nothing was delivered - return; - } - - postClusterToEventBus(new ReceivedDiscordMessageClusterImpl(messages)); - }) - .exceptionally(t -> { - if (t instanceof CompletionException) { - return null; - } - discordSRV.logger().error("Failed to publish to event bus", t); - TestHelper.fail(t); - return null; - }); + postClusterToEventBus(new ReceivedDiscordMessageClusterImpl(messages)); + }).exceptionally(t -> { + discordSRV.logger().error("Failed to publish to event bus", t); + TestHelper.fail(t); + return null; + }).thenApply(v -> (Void) null); }).exceptionally(t -> { - discordSRV.logger().error("Error in sending message", t); + discordSRV.logger().error("Error in forwarding message", t); TestHelper.fail(t); return null; }); } - public Map, DiscordGuildMessageChannel> sendMessageToChannels( + public List> sendMessageToChannels( T config, IPlayer player, SendableDiscordMessage.Builder format, @@ -179,16 +185,52 @@ public abstract class AbstractGameMessageModule, DiscordGuildMessageChannel> futures = new LinkedHashMap<>(); + List> futures = new ArrayList<>(); for (DiscordGuildMessageChannel channel : channels) { - futures.put(channel.sendMessage(discordMessage), channel); + futures.add(sendMessageToChannel(channel, discordMessage)); } return futures; } + @Nullable + protected final CompletableFuture sendMessageToChannel(DiscordGuildMessageChannel channel, SendableDiscordMessage message) { + GuildChannel permissionChannel = (GuildMessageChannel) channel.getAsJDAMessageChannel(); + + Permission sendPermission; + if (message.isWebhookMessage()) { + if (permissionChannel instanceof ThreadChannel) { + permissionChannel = ((ThreadChannel) permissionChannel).getParentChannel(); + } + sendPermission = Permission.MANAGE_WEBHOOKS; + } else { + sendPermission = permissionChannel instanceof ThreadChannel + ? Permission.MESSAGE_SEND_IN_THREADS + : Permission.MESSAGE_SEND; + } + + String missingPermissions = DiscordPermissionUtil.missingPermissionsString(permissionChannel, Permission.VIEW_CHANNEL, sendPermission); + if (missingPermissions != null) { + logger().error("Failed to send message to " + describeDestination(channel) + ": " + missingPermissions); + return CompletableFuture.completedFuture(null); + } + + return channel.sendMessage(message).exceptionally(t -> { + ErrorCallbackContext.context("Failed to deliver a message to " + describeDestination(channel)).accept(t); + TestHelper.fail(t); + return null; + }); + } + + private String describeDestination(DiscordGuildChannel channel) { + if (channel instanceof DiscordThreadChannel) { + return "\"" + channel.getName() + "\" in #" + ((DiscordThreadChannel) channel).getParentChannel().getName(); + } + return "#" + channel.getName(); + } + public abstract void setPlaceholders(T config, E event, SendableDiscordMessage.Formatter formatter); } diff --git a/common/src/main/java/com/discordsrv/common/messageforwarding/game/AwardMessageModule.java b/common/src/main/java/com/discordsrv/common/messageforwarding/game/AwardMessageModule.java index fff0b851..11b134f4 100644 --- a/common/src/main/java/com/discordsrv/common/messageforwarding/game/AwardMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/messageforwarding/game/AwardMessageModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/messageforwarding/game/DeathMessageModule.java b/common/src/main/java/com/discordsrv/common/messageforwarding/game/DeathMessageModule.java index d947e588..5447cbe4 100644 --- a/common/src/main/java/com/discordsrv/common/messageforwarding/game/DeathMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/messageforwarding/game/DeathMessageModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/messageforwarding/game/JoinMessageModule.java b/common/src/main/java/com/discordsrv/common/messageforwarding/game/JoinMessageModule.java index 63769758..ec4ef707 100644 --- a/common/src/main/java/com/discordsrv/common/messageforwarding/game/JoinMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/messageforwarding/game/JoinMessageModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -29,16 +29,24 @@ import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.component.util.ComponentUtil; import com.discordsrv.common.config.main.channels.base.BaseChannelConfig; import com.discordsrv.common.config.main.generic.IMessageConfig; +import com.discordsrv.common.event.events.player.PlayerDisconnectedEvent; import com.discordsrv.common.permission.Permission; import com.discordsrv.common.player.IPlayer; import net.kyori.adventure.text.Component; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.time.Duration; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Future; public class JoinMessageModule extends AbstractGameMessageModule { + private final Map> delayedTasks = new HashMap<>(); + public JoinMessageModule(DiscordSRV discordSRV) { super(discordSRV, "JOIN_MESSAGES"); } @@ -63,9 +71,35 @@ public class JoinMessageModule extends AbstractGameMessageModule 0) { + UUID playerUUID = player.uniqueId(); + + CompletableFuture completableFuture = new CompletableFuture<>(); + synchronized (delayedTasks) { + CompletableFuture future = discordSRV.scheduler() + .supplyLater(() -> super.forwardToChannel(event, player, config), Duration.ofMillis(delay)) + .thenCompose(r -> r) + .whenComplete((v, t) -> delayedTasks.remove(playerUUID)); + + delayedTasks.put(playerUUID, future); + } + return completableFuture; + } return super.forwardToChannel(event, player, config); } + @Subscribe + public void onPlayerDisconnected(PlayerDisconnectedEvent event) { + IPlayer player = event.player(); + Future future = delayedTasks.remove(player.uniqueId()); + if (future != null) { + future.cancel(true); + logger().info(player.username() + " left within timeout period, join message will not be sent"); + } + } + @Override public IMessageConfig mapConfig(JoinMessageReceiveEvent event, BaseChannelConfig channelConfig) { return channelConfig.joinMessages().getForEvent(event); diff --git a/common/src/main/java/com/discordsrv/common/messageforwarding/game/LeaveMessageModule.java b/common/src/main/java/com/discordsrv/common/messageforwarding/game/LeaveMessageModule.java index 091bda6a..1a276569 100644 --- a/common/src/main/java/com/discordsrv/common/messageforwarding/game/LeaveMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/messageforwarding/game/LeaveMessageModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -29,20 +29,51 @@ import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.component.util.ComponentUtil; import com.discordsrv.common.config.main.channels.LeaveMessageConfig; import com.discordsrv.common.config.main.channels.base.BaseChannelConfig; +import com.discordsrv.common.event.events.player.PlayerConnectedEvent; import com.discordsrv.common.permission.Permission; import com.discordsrv.common.player.IPlayer; import net.kyori.adventure.text.Component; +import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.time.Duration; +import java.util.Map; +import java.util.UUID; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Future; public class LeaveMessageModule extends AbstractGameMessageModule { + private final Map>> playersJoinedRecently = new ConcurrentHashMap<>(); + public LeaveMessageModule(DiscordSRV discordSRV) { super(discordSRV, "LEAVE_MESSAGES"); } + @Subscribe + public void onPlayerConnected(PlayerConnectedEvent event) { + UUID playerUUID = event.player().uniqueId(); + Pair> pair = playersJoinedRecently.remove(playerUUID); + if (pair != null) { + pair.getValue().cancel(true); + } + + long maxMS = 0; + for (BaseChannelConfig channel : discordSRV.channelConfig().getAllChannels()) { + long ms = channel.leaveMessages.ignoreIfJoinedWithinMS; + if (maxMS < ms) { + maxMS = ms; + } + } + if (maxMS > 0) { + long currentTime = System.currentTimeMillis(); + Future removeFuture = discordSRV.scheduler().runLater(() -> playersJoinedRecently.remove(playerUUID), Duration.ofMillis(maxMS)); + playersJoinedRecently.put(playerUUID, Pair.of(currentTime, removeFuture)); + } + } + @Subscribe(priority = EventPriority.LAST) public void onLeaveMessageReceive(LeaveMessageReceiveEvent event) { if (checkCancellation(event) || checkProcessor(event)) { @@ -59,6 +90,17 @@ public class LeaveMessageModule extends AbstractGameMessageModule> pair = playersJoinedRecently.remove(player.uniqueId()); + if (pair != null) { + long delta = System.currentTimeMillis() - pair.getKey(); + if (delta < config.leaveMessages.ignoreIfJoinedWithinMS) { + logger().info(player.username() + " joined within timeout period, join message will not be sent"); + return CompletableFuture.completedFuture(null); + } + } + } + if (config.leaveMessages.enableSilentPermission && player != null && player.hasPermission(Permission.SILENT_QUIT)) { logger().info(player.username() + " is leaving silently, leave message will not be sent"); return CompletableFuture.completedFuture(null); diff --git a/common/src/main/java/com/discordsrv/common/messageforwarding/game/ServerSwitchMessageModule.java b/common/src/main/java/com/discordsrv/common/messageforwarding/game/ServerSwitchMessageModule.java index 7c275c48..3664db8b 100644 --- a/common/src/main/java/com/discordsrv/common/messageforwarding/game/ServerSwitchMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/messageforwarding/game/ServerSwitchMessageModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/messageforwarding/game/StartMessageModule.java b/common/src/main/java/com/discordsrv/common/messageforwarding/game/StartMessageModule.java index 409a9cfb..a9682eb1 100644 --- a/common/src/main/java/com/discordsrv/common/messageforwarding/game/StartMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/messageforwarding/game/StartMessageModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -30,7 +30,7 @@ import com.discordsrv.common.player.IPlayer; import java.util.Collection; import java.util.Collections; -import java.util.Map; +import java.util.List; import java.util.concurrent.CompletableFuture; public class StartMessageModule extends AbstractGameMessageModule { @@ -53,7 +53,7 @@ public class StartMessageModule extends AbstractGameMessageModule, DiscordGuildMessageChannel> sendMessageToChannels( + public List> sendMessageToChannels( StartMessageConfig config, IPlayer player, SendableDiscordMessage.Builder format, @@ -62,7 +62,7 @@ public class StartMessageModule extends AbstractGameMessageModule, DiscordGuildMessageChannel> sendMessageToChannels( + public List> sendMessageToChannels( StopMessageConfig config, IPlayer player, SendableDiscordMessage.Builder format, @@ -65,7 +65,7 @@ public class StopMessageModule extends AbstractGameMessageModule { super(discordSRV); } + @Override + public @NotNull Collection requiredIntents() { + boolean anyUserMentions = false; + for (BaseChannelConfig channel : discordSRV.channelConfig().getAllChannels()) { + MinecraftToDiscordChatConfig config = channel.minecraftToDiscord; + if (!config.enabled) { + continue; + } + + MinecraftToDiscordChatConfig.Mentions mentions = config.mentions; + if (mentions.users) { + anyUserMentions = true; + break; + } + } + + if (anyUserMentions) { + return EnumSet.of(DiscordGatewayIntent.GUILD_MEMBERS); + } + + return Collections.emptySet(); + } + @Override public boolean isEnabled() { for (BaseChannelConfig channel : discordSRV.channelConfig().getAllChannels()) { diff --git a/common/src/main/java/com/discordsrv/common/messageforwarding/game/minecrafttodiscord/MinecraftToDiscordChatModule.java b/common/src/main/java/com/discordsrv/common/messageforwarding/game/minecrafttodiscord/MinecraftToDiscordChatModule.java index 0c7fdcb0..f4720870 100644 --- a/common/src/main/java/com/discordsrv/common/messageforwarding/game/minecrafttodiscord/MinecraftToDiscordChatModule.java +++ b/common/src/main/java/com/discordsrv/common/messageforwarding/game/minecrafttodiscord/MinecraftToDiscordChatModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -78,7 +78,7 @@ public class MinecraftToDiscordChatModule extends AbstractGameMessageModule, DiscordGuildMessageChannel> sendMessageToChannels( + public List> sendMessageToChannels( MinecraftToDiscordChatConfig config, IPlayer player, SendableDiscordMessage.Builder format, @@ -95,7 +95,7 @@ public class MinecraftToDiscordChatModule extends AbstractGameMessageModule, DiscordGuildMessageChannel> futures = new LinkedHashMap<>(); + List> futures = new ArrayList<>(); // Format messages per-Guild for (Map.Entry> entry : channelMap.entrySet()) { @@ -103,7 +103,7 @@ public class MinecraftToDiscordChatModule extends AbstractGameMessageModule messageFuture = getMessageForGuild(config, format, guild, message, player, context); for (DiscordGuildMessageChannel channel : entry.getValue()) { - futures.put(messageFuture.thenCompose(channel::sendMessage), channel); + futures.add(messageFuture.thenCompose(msg -> sendMessageToChannel(channel, msg))); } } diff --git a/common/src/main/java/com/discordsrv/common/module/ModuleManager.java b/common/src/main/java/com/discordsrv/common/module/ModuleManager.java index 66b19c2b..8d76461b 100644 --- a/common/src/main/java/com/discordsrv/common/module/ModuleManager.java +++ b/common/src/main/java/com/discordsrv/common/module/ModuleManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/module/type/AbstractModule.java b/common/src/main/java/com/discordsrv/common/module/type/AbstractModule.java index 6d0b7319..ccef2740 100644 --- a/common/src/main/java/com/discordsrv/common/module/type/AbstractModule.java +++ b/common/src/main/java/com/discordsrv/common/module/type/AbstractModule.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/module/type/ModuleDelegate.java b/common/src/main/java/com/discordsrv/common/module/type/ModuleDelegate.java index 1a877260..e658ee97 100644 --- a/common/src/main/java/com/discordsrv/common/module/type/ModuleDelegate.java +++ b/common/src/main/java/com/discordsrv/common/module/type/ModuleDelegate.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/module/type/PluginIntegration.java b/common/src/main/java/com/discordsrv/common/module/type/PluginIntegration.java index 37dfa905..109dff8c 100644 --- a/common/src/main/java/com/discordsrv/common/module/type/PluginIntegration.java +++ b/common/src/main/java/com/discordsrv/common/module/type/PluginIntegration.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/paste/Paste.java b/common/src/main/java/com/discordsrv/common/paste/Paste.java index f2e4af69..0eef382d 100644 --- a/common/src/main/java/com/discordsrv/common/paste/Paste.java +++ b/common/src/main/java/com/discordsrv/common/paste/Paste.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/paste/PasteService.java b/common/src/main/java/com/discordsrv/common/paste/PasteService.java index 8a0018ef..efc42902 100644 --- a/common/src/main/java/com/discordsrv/common/paste/PasteService.java +++ b/common/src/main/java/com/discordsrv/common/paste/PasteService.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/paste/service/AESEncryptedPasteService.java b/common/src/main/java/com/discordsrv/common/paste/service/AESEncryptedPasteService.java index 3c495a26..fa32fdec 100644 --- a/common/src/main/java/com/discordsrv/common/paste/service/AESEncryptedPasteService.java +++ b/common/src/main/java/com/discordsrv/common/paste/service/AESEncryptedPasteService.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/paste/service/BinPasteService.java b/common/src/main/java/com/discordsrv/common/paste/service/BinPasteService.java index 437281e7..54fab957 100644 --- a/common/src/main/java/com/discordsrv/common/paste/service/BinPasteService.java +++ b/common/src/main/java/com/discordsrv/common/paste/service/BinPasteService.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/paste/service/BytebinPasteService.java b/common/src/main/java/com/discordsrv/common/paste/service/BytebinPasteService.java index 40e854cf..de0c23ba 100644 --- a/common/src/main/java/com/discordsrv/common/paste/service/BytebinPasteService.java +++ b/common/src/main/java/com/discordsrv/common/paste/service/BytebinPasteService.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/permission/Permission.java b/common/src/main/java/com/discordsrv/common/permission/Permission.java index 5d14bb01..2a65d5d5 100644 --- a/common/src/main/java/com/discordsrv/common/permission/Permission.java +++ b/common/src/main/java/com/discordsrv/common/permission/Permission.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.permission; public enum Permission { diff --git a/common/src/main/java/com/discordsrv/common/permission/util/PermissionUtil.java b/common/src/main/java/com/discordsrv/common/permission/util/PermissionUtil.java index 65daea8d..d0eecfe9 100644 --- a/common/src/main/java/com/discordsrv/common/permission/util/PermissionUtil.java +++ b/common/src/main/java/com/discordsrv/common/permission/util/PermissionUtil.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/placeholder/DiscordPlaceholdersImpl.java b/common/src/main/java/com/discordsrv/common/placeholder/DiscordPlaceholdersImpl.java index 03569e50..a1a2a38e 100644 --- a/common/src/main/java/com/discordsrv/common/placeholder/DiscordPlaceholdersImpl.java +++ b/common/src/main/java/com/discordsrv/common/placeholder/DiscordPlaceholdersImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/placeholder/PlaceholderServiceImpl.java b/common/src/main/java/com/discordsrv/common/placeholder/PlaceholderServiceImpl.java index a7edd574..45f7c70b 100644 --- a/common/src/main/java/com/discordsrv/common/placeholder/PlaceholderServiceImpl.java +++ b/common/src/main/java/com/discordsrv/common/placeholder/PlaceholderServiceImpl.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/placeholder/context/GlobalDateFormattingContext.java b/common/src/main/java/com/discordsrv/common/placeholder/context/GlobalDateFormattingContext.java index f7af4ecf..1000a330 100644 --- a/common/src/main/java/com/discordsrv/common/placeholder/context/GlobalDateFormattingContext.java +++ b/common/src/main/java/com/discordsrv/common/placeholder/context/GlobalDateFormattingContext.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.placeholder.context; import com.discordsrv.api.placeholder.annotation.Placeholder; diff --git a/common/src/main/java/com/discordsrv/common/placeholder/context/GlobalTextHandlingContext.java b/common/src/main/java/com/discordsrv/common/placeholder/context/GlobalTextHandlingContext.java index c01a3729..db28d7f7 100644 --- a/common/src/main/java/com/discordsrv/common/placeholder/context/GlobalTextHandlingContext.java +++ b/common/src/main/java/com/discordsrv/common/placeholder/context/GlobalTextHandlingContext.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/placeholder/provider/AnnotationPlaceholderProvider.java b/common/src/main/java/com/discordsrv/common/placeholder/provider/AnnotationPlaceholderProvider.java index ee6ba9fe..709c2115 100644 --- a/common/src/main/java/com/discordsrv/common/placeholder/provider/AnnotationPlaceholderProvider.java +++ b/common/src/main/java/com/discordsrv/common/placeholder/provider/AnnotationPlaceholderProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/placeholder/provider/util/PlaceholderMethodUtil.java b/common/src/main/java/com/discordsrv/common/placeholder/provider/util/PlaceholderMethodUtil.java index 8341fc92..b2921b2c 100644 --- a/common/src/main/java/com/discordsrv/common/placeholder/provider/util/PlaceholderMethodUtil.java +++ b/common/src/main/java/com/discordsrv/common/placeholder/provider/util/PlaceholderMethodUtil.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/placeholder/result/ComponentResultStringifier.java b/common/src/main/java/com/discordsrv/common/placeholder/result/ComponentResultStringifier.java index ab22e524..5b03f332 100644 --- a/common/src/main/java/com/discordsrv/common/placeholder/result/ComponentResultStringifier.java +++ b/common/src/main/java/com/discordsrv/common/placeholder/result/ComponentResultStringifier.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/player/IOfflinePlayer.java b/common/src/main/java/com/discordsrv/common/player/IOfflinePlayer.java index 911a1013..510ef031 100644 --- a/common/src/main/java/com/discordsrv/common/player/IOfflinePlayer.java +++ b/common/src/main/java/com/discordsrv/common/player/IOfflinePlayer.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/player/IPlayer.java b/common/src/main/java/com/discordsrv/common/player/IPlayer.java index d377bc99..c6cb94d5 100644 --- a/common/src/main/java/com/discordsrv/common/player/IPlayer.java +++ b/common/src/main/java/com/discordsrv/common/player/IPlayer.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/player/OfflinePlayer.java b/common/src/main/java/com/discordsrv/common/player/OfflinePlayer.java index 1e99ce30..c54cf74d 100644 --- a/common/src/main/java/com/discordsrv/common/player/OfflinePlayer.java +++ b/common/src/main/java/com/discordsrv/common/player/OfflinePlayer.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.player; import com.discordsrv.common.DiscordSRV; diff --git a/common/src/main/java/com/discordsrv/common/player/provider/AbstractPlayerProvider.java b/common/src/main/java/com/discordsrv/common/player/provider/AbstractPlayerProvider.java index fbe34486..db9f183b 100644 --- a/common/src/main/java/com/discordsrv/common/player/provider/AbstractPlayerProvider.java +++ b/common/src/main/java/com/discordsrv/common/player/provider/AbstractPlayerProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/player/provider/PlayerProvider.java b/common/src/main/java/com/discordsrv/common/player/provider/PlayerProvider.java index 22851f92..4e60fab8 100644 --- a/common/src/main/java/com/discordsrv/common/player/provider/PlayerProvider.java +++ b/common/src/main/java/com/discordsrv/common/player/provider/PlayerProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/player/provider/ServerPlayerProvider.java b/common/src/main/java/com/discordsrv/common/player/provider/ServerPlayerProvider.java index fd41928a..33d0e67a 100644 --- a/common/src/main/java/com/discordsrv/common/player/provider/ServerPlayerProvider.java +++ b/common/src/main/java/com/discordsrv/common/player/provider/ServerPlayerProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/player/provider/model/GameProfileResponse.java b/common/src/main/java/com/discordsrv/common/player/provider/model/GameProfileResponse.java index e21da4f8..e2e15810 100644 --- a/common/src/main/java/com/discordsrv/common/player/provider/model/GameProfileResponse.java +++ b/common/src/main/java/com/discordsrv/common/player/provider/model/GameProfileResponse.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.player.provider.model; import java.util.List; diff --git a/common/src/main/java/com/discordsrv/common/player/provider/model/SkinInfo.java b/common/src/main/java/com/discordsrv/common/player/provider/model/SkinInfo.java index 9c0967bc..4381df2b 100644 --- a/common/src/main/java/com/discordsrv/common/player/provider/model/SkinInfo.java +++ b/common/src/main/java/com/discordsrv/common/player/provider/model/SkinInfo.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.player.provider.model; public class SkinInfo { diff --git a/common/src/main/java/com/discordsrv/common/player/provider/model/Textures.java b/common/src/main/java/com/discordsrv/common/player/provider/model/Textures.java index ec84a012..778537ce 100644 --- a/common/src/main/java/com/discordsrv/common/player/provider/model/Textures.java +++ b/common/src/main/java/com/discordsrv/common/player/provider/model/Textures.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.player.provider.model; import com.discordsrv.common.DiscordSRV; diff --git a/common/src/main/java/com/discordsrv/common/player/provider/model/UUIDResponse.java b/common/src/main/java/com/discordsrv/common/player/provider/model/UUIDResponse.java index ad3d3417..4dcd5566 100644 --- a/common/src/main/java/com/discordsrv/common/player/provider/model/UUIDResponse.java +++ b/common/src/main/java/com/discordsrv/common/player/provider/model/UUIDResponse.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.player.provider.model; public class UUIDResponse { diff --git a/common/src/main/java/com/discordsrv/common/plugin/Plugin.java b/common/src/main/java/com/discordsrv/common/plugin/Plugin.java index e86f16fd..211a6c7d 100644 --- a/common/src/main/java/com/discordsrv/common/plugin/Plugin.java +++ b/common/src/main/java/com/discordsrv/common/plugin/Plugin.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/plugin/PluginManager.java b/common/src/main/java/com/discordsrv/common/plugin/PluginManager.java index 45882b1b..b899a891 100644 --- a/common/src/main/java/com/discordsrv/common/plugin/PluginManager.java +++ b/common/src/main/java/com/discordsrv/common/plugin/PluginManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/profile/Profile.java b/common/src/main/java/com/discordsrv/common/profile/Profile.java index 6bc3af79..908a27ec 100644 --- a/common/src/main/java/com/discordsrv/common/profile/Profile.java +++ b/common/src/main/java/com/discordsrv/common/profile/Profile.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/profile/ProfileManager.java b/common/src/main/java/com/discordsrv/common/profile/ProfileManager.java index 2615571e..9b32f7ae 100644 --- a/common/src/main/java/com/discordsrv/common/profile/ProfileManager.java +++ b/common/src/main/java/com/discordsrv/common/profile/ProfileManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/scheduler/Scheduler.java b/common/src/main/java/com/discordsrv/common/scheduler/Scheduler.java index 244e7f1b..e7f4b8e4 100644 --- a/common/src/main/java/com/discordsrv/common/scheduler/Scheduler.java +++ b/common/src/main/java/com/discordsrv/common/scheduler/Scheduler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -18,7 +18,9 @@ package com.discordsrv.common.scheduler; -import org.jetbrains.annotations.ApiStatus; +import com.discordsrv.common.function.CheckedRunnable; +import com.discordsrv.common.function.CheckedSupplier; +import com.discordsrv.common.future.util.CompletableFutureUtil; import org.jetbrains.annotations.NotNull; import java.time.Duration; @@ -61,15 +63,37 @@ public interface Scheduler { * * @param task the task */ + @NotNull Future run(@NotNull Runnable task); + @NotNull + default CompletableFuture execute(@NotNull CheckedRunnable task) { + return CompletableFutureUtil.runAsync(task, this::run); + } + + @NotNull + default CompletableFuture supply(@NotNull CheckedSupplier supplier) { + return CompletableFutureUtil.supplyAsync(supplier, this::run); + } + /** * Schedules the given task after the provided amount of milliseconds. * * @param task the task * @param delay the delay before executing the task */ - ScheduledFuture runLater(Runnable task, Duration delay); + @NotNull + ScheduledFuture runLater(@NotNull Runnable task, @NotNull Duration delay); + + @NotNull + default CompletableFuture executeLater(@NotNull CheckedRunnable task, @NotNull Duration delay) { + return CompletableFutureUtil.runAsync(task, t -> runLater(t, delay)); + } + + @NotNull + default CompletableFuture supplyLater(@NotNull CheckedSupplier supplier, @NotNull Duration delay) { + return CompletableFutureUtil.supplyAsync(supplier, task -> runLater(task, delay)); + } /** * Schedules the given task at the given rate. @@ -77,7 +101,7 @@ public interface Scheduler { * @param task the task * @param rate the rate in the given unit */ - @ApiStatus.NonExtendable + @NotNull default ScheduledFuture runAtFixedRate(@NotNull Runnable task, Duration rate) { return runAtFixedRate(task, rate, rate); } @@ -89,7 +113,7 @@ public interface Scheduler { * @param initialDelay the initial delay in the provided unit * @param rate the rate to run the task at in the given unit */ - @ApiStatus.NonExtendable + @NotNull ScheduledFuture runAtFixedRate(@NotNull Runnable task, Duration initialDelay, Duration rate); } diff --git a/common/src/main/java/com/discordsrv/common/scheduler/ServerScheduler.java b/common/src/main/java/com/discordsrv/common/scheduler/ServerScheduler.java index efeb0bc4..6ead8e4d 100644 --- a/common/src/main/java/com/discordsrv/common/scheduler/ServerScheduler.java +++ b/common/src/main/java/com/discordsrv/common/scheduler/ServerScheduler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -18,8 +18,12 @@ package com.discordsrv.common.scheduler; -import org.jetbrains.annotations.ApiStatus; +import com.discordsrv.common.function.CheckedRunnable; +import com.discordsrv.common.function.CheckedSupplier; +import com.discordsrv.common.future.util.CompletableFutureUtil; +import org.jetbrains.annotations.NotNull; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; @SuppressWarnings("unused") // API @@ -44,7 +48,17 @@ public interface ServerScheduler extends Scheduler { * Runs the provided task on the server's main thread as soon as possible. * @param task the task */ - void runOnMainThread(Runnable task); + void runOnMainThread(@NotNull Runnable task); + + @NotNull + default CompletableFuture supplyOnMainThread(@NotNull CheckedRunnable task) { + return CompletableFutureUtil.runAsync(task, this::runOnMainThread); + } + + @NotNull + default CompletableFuture supplyOnMainThread(@NotNull CheckedSupplier task) { + return CompletableFutureUtil.supplyAsync(task, this::runOnMainThread); + } /** * Runs the provided task in on the server's main thread in the provided amount of ticks. @@ -53,7 +67,17 @@ public interface ServerScheduler extends Scheduler { * @see #TICKS_PER_SECOND * @see #timeToTicks(long, TimeUnit) */ - void runOnMainThreadLaterInTicks(Runnable task, int ticks); + void runOnMainThreadLaterInTicks(@NotNull Runnable task, int ticks); + + @NotNull + default CompletableFuture executeOnMainThreadLaterInTicks(@NotNull CheckedRunnable task, int ticks) { + return CompletableFutureUtil.runAsync(task, t -> runOnMainThreadLaterInTicks(t, ticks)); + } + + @NotNull + default CompletableFuture supplyOnMainThreadLaterInTicks(@NotNull CheckedSupplier task, int ticks) { + return CompletableFutureUtil.supplyAsync(task, t -> runOnMainThreadLaterInTicks(t, ticks)); + } /** * Runs the task on the server's main thread continuously at provided rate in ticks. @@ -61,8 +85,7 @@ public interface ServerScheduler extends Scheduler { * @param task the task * @param rateTicks the rate in ticks */ - @ApiStatus.NonExtendable - default void runOnMainThreadAtFixedRateInTicks(Runnable task, int rateTicks) { + default void runOnMainThreadAtFixedRateInTicks(@NotNull Runnable task, int rateTicks) { runOnMainThreadAtFixedRateInTicks(task, 0, rateTicks); } @@ -73,7 +96,7 @@ public interface ServerScheduler extends Scheduler { * @param initialTicks the initial delay in ticks * @param rateTicks the rate in ticks */ - void runOnMainThreadAtFixedRateInTicks(Runnable task, int initialTicks, int rateTicks); + void runOnMainThreadAtFixedRateInTicks(@NotNull Runnable task, int initialTicks, int rateTicks); } diff --git a/common/src/main/java/com/discordsrv/common/scheduler/StandardScheduler.java b/common/src/main/java/com/discordsrv/common/scheduler/StandardScheduler.java index d8c0c0ee..1dda2343 100644 --- a/common/src/main/java/com/discordsrv/common/scheduler/StandardScheduler.java +++ b/common/src/main/java/com/discordsrv/common/scheduler/StandardScheduler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -120,17 +120,17 @@ public class StandardScheduler implements Scheduler { } @Override - public Future run(@NotNull Runnable task) { + public @NotNull Future run(@NotNull Runnable task) { return executorService.submit(wrap(task)); } @Override - public ScheduledFuture runLater(Runnable task, Duration delay) { + public @NotNull ScheduledFuture runLater(@NotNull Runnable task, @NotNull Duration delay) { return scheduledExecutorService.schedule(wrap(task), delay.toMillis(), TimeUnit.MILLISECONDS); } @Override - public ScheduledFuture runAtFixedRate(@NotNull Runnable task, Duration initialDelay, Duration rate) { + public @NotNull ScheduledFuture runAtFixedRate(@NotNull Runnable task, Duration initialDelay, Duration rate) { return scheduledExecutorService.scheduleAtFixedRate(wrap(task), initialDelay.toMillis(), rate.toMillis(), TimeUnit.MILLISECONDS); } diff --git a/common/src/main/java/com/discordsrv/common/scheduler/executor/DynamicCachingThreadPoolExecutor.java b/common/src/main/java/com/discordsrv/common/scheduler/executor/DynamicCachingThreadPoolExecutor.java index bf058a95..2add1888 100644 --- a/common/src/main/java/com/discordsrv/common/scheduler/executor/DynamicCachingThreadPoolExecutor.java +++ b/common/src/main/java/com/discordsrv/common/scheduler/executor/DynamicCachingThreadPoolExecutor.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.scheduler.executor; import org.jetbrains.annotations.NotNull; diff --git a/common/src/main/java/com/discordsrv/common/scheduler/threadfactory/CountingFactory.java b/common/src/main/java/com/discordsrv/common/scheduler/threadfactory/CountingFactory.java index 3672ca7b..e55c7288 100644 --- a/common/src/main/java/com/discordsrv/common/scheduler/threadfactory/CountingFactory.java +++ b/common/src/main/java/com/discordsrv/common/scheduler/threadfactory/CountingFactory.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/scheduler/threadfactory/CountingForkJoinWorkerThreadFactory.java b/common/src/main/java/com/discordsrv/common/scheduler/threadfactory/CountingForkJoinWorkerThreadFactory.java index cea41d97..c4199b86 100644 --- a/common/src/main/java/com/discordsrv/common/scheduler/threadfactory/CountingForkJoinWorkerThreadFactory.java +++ b/common/src/main/java/com/discordsrv/common/scheduler/threadfactory/CountingForkJoinWorkerThreadFactory.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/scheduler/threadfactory/CountingThreadFactory.java b/common/src/main/java/com/discordsrv/common/scheduler/threadfactory/CountingThreadFactory.java index e53392de..9fb6ea66 100644 --- a/common/src/main/java/com/discordsrv/common/scheduler/threadfactory/CountingThreadFactory.java +++ b/common/src/main/java/com/discordsrv/common/scheduler/threadfactory/CountingThreadFactory.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/storage/Storage.java b/common/src/main/java/com/discordsrv/common/storage/Storage.java index 7b7063e6..a45ec895 100644 --- a/common/src/main/java/com/discordsrv/common/storage/Storage.java +++ b/common/src/main/java/com/discordsrv/common/storage/Storage.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/storage/StorageType.java b/common/src/main/java/com/discordsrv/common/storage/StorageType.java index 18baa7db..d4da48b7 100644 --- a/common/src/main/java/com/discordsrv/common/storage/StorageType.java +++ b/common/src/main/java/com/discordsrv/common/storage/StorageType.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/storage/impl/MemoryStorage.java b/common/src/main/java/com/discordsrv/common/storage/impl/MemoryStorage.java index 90782e44..35f4ec61 100644 --- a/common/src/main/java/com/discordsrv/common/storage/impl/MemoryStorage.java +++ b/common/src/main/java/com/discordsrv/common/storage/impl/MemoryStorage.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.storage.impl; import com.discordsrv.common.storage.Storage; diff --git a/common/src/main/java/com/discordsrv/common/storage/impl/package-info.java b/common/src/main/java/com/discordsrv/common/storage/impl/package-info.java index 33568e76..0372c07b 100644 --- a/common/src/main/java/com/discordsrv/common/storage/impl/package-info.java +++ b/common/src/main/java/com/discordsrv/common/storage/impl/package-info.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/storage/impl/sql/SQLStorage.java b/common/src/main/java/com/discordsrv/common/storage/impl/sql/SQLStorage.java index 11cd5d06..16bcb15a 100644 --- a/common/src/main/java/com/discordsrv/common/storage/impl/sql/SQLStorage.java +++ b/common/src/main/java/com/discordsrv/common/storage/impl/sql/SQLStorage.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/storage/impl/sql/file/H2Storage.java b/common/src/main/java/com/discordsrv/common/storage/impl/sql/file/H2Storage.java index 8f849ce9..fabcec55 100644 --- a/common/src/main/java/com/discordsrv/common/storage/impl/sql/file/H2Storage.java +++ b/common/src/main/java/com/discordsrv/common/storage/impl/sql/file/H2Storage.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -43,7 +43,7 @@ public class H2Storage extends SQLStorage { @Override public void initialize() { try { - classLoader = discordSRV.dependencyManager().h2().loadIntoIsolated(); + classLoader = discordSRV.dependencyManager().h2().intoIsolated(); } catch (IOException e) { throw new StorageException(e); } diff --git a/common/src/main/java/com/discordsrv/common/storage/impl/sql/hikari/HikariStorage.java b/common/src/main/java/com/discordsrv/common/storage/impl/sql/hikari/HikariStorage.java index e05eb4aa..6b28707f 100644 --- a/common/src/main/java/com/discordsrv/common/storage/impl/sql/hikari/HikariStorage.java +++ b/common/src/main/java/com/discordsrv/common/storage/impl/sql/hikari/HikariStorage.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/storage/impl/sql/hikari/MariaDBStorage.java b/common/src/main/java/com/discordsrv/common/storage/impl/sql/hikari/MariaDBStorage.java index 2bf84c3c..e9d66ef4 100644 --- a/common/src/main/java/com/discordsrv/common/storage/impl/sql/hikari/MariaDBStorage.java +++ b/common/src/main/java/com/discordsrv/common/storage/impl/sql/hikari/MariaDBStorage.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.storage.impl.sql.hikari; import com.discordsrv.common.DiscordSRV; @@ -23,7 +41,7 @@ public class MariaDBStorage extends HikariStorage { @Override public void initialize() { try { - discordSRV.dependencyManager().mariadb().download().join(); + discordSRV.dependencyManager().mariadb().downloadRelocateAndLoad().join(); super.initialize(); } catch (IOException e) { throw new StorageException(e); diff --git a/common/src/main/java/com/discordsrv/common/storage/impl/sql/hikari/MySQLStorage.java b/common/src/main/java/com/discordsrv/common/storage/impl/sql/hikari/MySQLStorage.java index cc8a81e1..58259732 100644 --- a/common/src/main/java/com/discordsrv/common/storage/impl/sql/hikari/MySQLStorage.java +++ b/common/src/main/java/com/discordsrv/common/storage/impl/sql/hikari/MySQLStorage.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -79,7 +79,7 @@ public class MySQLStorage extends HikariStorage { @Override public void initialize() { try { - initializeWithContext(classLoader = discordSRV.dependencyManager().mysql().loadIntoIsolated()); + initializeWithContext(classLoader = discordSRV.dependencyManager().mysql().intoIsolated()); } catch (IOException e) { throw new StorageException(e); } diff --git a/common/src/main/java/com/discordsrv/common/sync/enums/SyncDirection.java b/common/src/main/java/com/discordsrv/common/sync/enums/SyncDirection.java index c22a51b3..a81dd590 100644 --- a/common/src/main/java/com/discordsrv/common/sync/enums/SyncDirection.java +++ b/common/src/main/java/com/discordsrv/common/sync/enums/SyncDirection.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/sync/enums/SyncSide.java b/common/src/main/java/com/discordsrv/common/sync/enums/SyncSide.java index c6bf849a..5e811f23 100644 --- a/common/src/main/java/com/discordsrv/common/sync/enums/SyncSide.java +++ b/common/src/main/java/com/discordsrv/common/sync/enums/SyncSide.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/testing/TestHelper.java b/common/src/main/java/com/discordsrv/common/testing/TestHelper.java index db72d6b2..60f6b019 100644 --- a/common/src/main/java/com/discordsrv/common/testing/TestHelper.java +++ b/common/src/main/java/com/discordsrv/common/testing/TestHelper.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.testing; import java.util.function.Consumer; diff --git a/common/src/main/java/com/discordsrv/common/time/util/Timeout.java b/common/src/main/java/com/discordsrv/common/time/util/Timeout.java index ae4a5c6e..7be0db18 100644 --- a/common/src/main/java/com/discordsrv/common/time/util/Timeout.java +++ b/common/src/main/java/com/discordsrv/common/time/util/Timeout.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/update/UpdateChecker.java b/common/src/main/java/com/discordsrv/common/update/UpdateChecker.java index 93bed953..879ad3d3 100644 --- a/common/src/main/java/com/discordsrv/common/update/UpdateChecker.java +++ b/common/src/main/java/com/discordsrv/common/update/UpdateChecker.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/update/VersionCheck.java b/common/src/main/java/com/discordsrv/common/update/VersionCheck.java index 5faa0030..3d560fec 100644 --- a/common/src/main/java/com/discordsrv/common/update/VersionCheck.java +++ b/common/src/main/java/com/discordsrv/common/update/VersionCheck.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/update/github/GitHubCompareResponse.java b/common/src/main/java/com/discordsrv/common/update/github/GitHubCompareResponse.java index bd49ac67..2010d3d8 100644 --- a/common/src/main/java/com/discordsrv/common/update/github/GitHubCompareResponse.java +++ b/common/src/main/java/com/discordsrv/common/update/github/GitHubCompareResponse.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/update/github/GithubRelease.java b/common/src/main/java/com/discordsrv/common/update/github/GithubRelease.java index c7e38a48..1de4b849 100644 --- a/common/src/main/java/com/discordsrv/common/update/github/GithubRelease.java +++ b/common/src/main/java/com/discordsrv/common/update/github/GithubRelease.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/main/java/com/discordsrv/common/uuid/util/UUIDUtil.java b/common/src/main/java/com/discordsrv/common/uuid/util/UUIDUtil.java index fb05fd9b..1565addd 100644 --- a/common/src/main/java/com/discordsrv/common/uuid/util/UUIDUtil.java +++ b/common/src/main/java/com/discordsrv/common/uuid/util/UUIDUtil.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.uuid.util; import com.discordsrv.api.placeholder.annotation.Placeholder; diff --git a/common/src/test/java/com/discordsrv/common/FullBootExtension.java b/common/src/test/java/com/discordsrv/common/FullBootExtension.java index 1407d733..09a9e979 100644 --- a/common/src/test/java/com/discordsrv/common/FullBootExtension.java +++ b/common/src/test/java/com/discordsrv/common/FullBootExtension.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common; import org.junit.jupiter.api.Assertions; @@ -9,6 +27,7 @@ public class FullBootExtension implements BeforeAllCallback, ExtensionContext.St public static String BOT_TOKEN = System.getenv("DISCORDSRV_AUTOTEST_BOT_TOKEN"); public static String TEST_CHANNEL_ID = System.getenv("DISCORDSRV_AUTOTEST_CHANNEL_ID"); + public static String FORUM_CHANNEL_ID = System.getenv("DISCORDSRV_AUTOTEST_FORUM_ID"); public boolean started = false; @@ -16,6 +35,7 @@ public class FullBootExtension implements BeforeAllCallback, ExtensionContext.St public void beforeAll(ExtensionContext context) { Assumptions.assumeTrue(BOT_TOKEN != null, "Automated testing bot token"); Assumptions.assumeTrue(TEST_CHANNEL_ID != null, "Automated testing channel id"); + Assumptions.assumeTrue(FORUM_CHANNEL_ID != null, "Automated testing forum id"); if (started) return; started = true; diff --git a/common/src/test/java/com/discordsrv/common/MockDiscordSRV.java b/common/src/test/java/com/discordsrv/common/MockDiscordSRV.java index 0d61cf53..0c0d1b1d 100644 --- a/common/src/test/java/com/discordsrv/common/MockDiscordSRV.java +++ b/common/src/test/java/com/discordsrv/common/MockDiscordSRV.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -21,6 +21,7 @@ package com.discordsrv.common; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.common.bootstrap.IBootstrap; import com.discordsrv.common.bootstrap.LifecycleManager; +import com.discordsrv.common.command.game.executor.CommandExecutorProvider; import com.discordsrv.common.command.game.handler.ICommandHandler; import com.discordsrv.common.config.configurate.manager.ConnectionConfigManager; import com.discordsrv.common.config.configurate.manager.MainConfigManager; @@ -36,8 +37,8 @@ import com.discordsrv.common.config.messages.MessagesConfig; import com.discordsrv.common.console.Console; import com.discordsrv.common.debug.data.OnlineMode; import com.discordsrv.common.debug.data.VersionInfo; -import com.discordsrv.common.exception.ConfigException; import com.discordsrv.common.logging.Logger; +import com.discordsrv.common.logging.backend.LoggingBackend; import com.discordsrv.common.logging.backend.impl.JavaLoggerImpl; import com.discordsrv.common.messageforwarding.game.minecrafttodiscord.MinecraftToDiscordChatModule; import com.discordsrv.common.player.IPlayer; @@ -47,6 +48,7 @@ import com.discordsrv.common.scheduler.Scheduler; import com.discordsrv.common.scheduler.StandardScheduler; import com.discordsrv.common.storage.impl.MemoryStorage; import dev.vankka.dependencydownload.classpath.ClasspathAppender; +import net.kyori.adventure.audience.Audience; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; @@ -124,7 +126,32 @@ public class MockDiscordSRV extends AbstractDiscordSRV channelIds = destination.channelIds; channelIds.clear(); @@ -222,9 +250,14 @@ public class MockDiscordSRV extends AbstractDiscordSRV threadConfigs = destination.threads; threadConfigs.clear(); + ThreadConfig thread = new ThreadConfig(); thread.channelId = channelId; threadConfigs.add(thread); + + ThreadConfig forumThread = new ThreadConfig(); + forumThread.channelId = forumId; + threadConfigs.add(forumThread); } return config; @@ -239,7 +272,7 @@ public class MockDiscordSRV extends AbstractDiscordSRV. + */ + package com.discordsrv.common.command.game; import com.discordsrv.common.config.main.generic.GameCommandExecutionConditionConfig; diff --git a/common/src/test/java/com/discordsrv/common/config/ConfigsLoadOnEnableTest.java b/common/src/test/java/com/discordsrv/common/config/ConfigsLoadOnEnableTest.java index a527dd50..61becbae 100644 --- a/common/src/test/java/com/discordsrv/common/config/ConfigsLoadOnEnableTest.java +++ b/common/src/test/java/com/discordsrv/common/config/ConfigsLoadOnEnableTest.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.config; import com.discordsrv.common.FullBootExtension; diff --git a/common/src/test/java/com/discordsrv/common/event/bus/EventBusTest.java b/common/src/test/java/com/discordsrv/common/event/bus/EventBusTest.java index 767374bd..7decc8fa 100644 --- a/common/src/test/java/com/discordsrv/common/event/bus/EventBusTest.java +++ b/common/src/test/java/com/discordsrv/common/event/bus/EventBusTest.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/test/java/com/discordsrv/common/linking/requirement/parser/RequirementParserTest.java b/common/src/test/java/com/discordsrv/common/linking/requirement/parser/RequirementParserTest.java index 2d16589a..023931cc 100644 --- a/common/src/test/java/com/discordsrv/common/linking/requirement/parser/RequirementParserTest.java +++ b/common/src/test/java/com/discordsrv/common/linking/requirement/parser/RequirementParserTest.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/test/java/com/discordsrv/common/messageforwarding/game/MinecraftToDiscordChatMessageTest.java b/common/src/test/java/com/discordsrv/common/messageforwarding/game/MinecraftToDiscordChatMessageTest.java index 7133ba4c..91715983 100644 --- a/common/src/test/java/com/discordsrv/common/messageforwarding/game/MinecraftToDiscordChatMessageTest.java +++ b/common/src/test/java/com/discordsrv/common/messageforwarding/game/MinecraftToDiscordChatMessageTest.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.messageforwarding.game; import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel; @@ -146,7 +164,7 @@ public class MinecraftToDiscordChatMessageTest { } } - success.complete(text == 1 && thread == 1); + success.complete(text == 1 && thread == 2); } } } diff --git a/common/src/test/java/com/discordsrv/common/placeholder/PlaceholderServiceTest.java b/common/src/test/java/com/discordsrv/common/placeholder/PlaceholderServiceTest.java index 2e8924c9..5a584f3a 100644 --- a/common/src/test/java/com/discordsrv/common/placeholder/PlaceholderServiceTest.java +++ b/common/src/test/java/com/discordsrv/common/placeholder/PlaceholderServiceTest.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/common/src/test/java/com/discordsrv/common/player/provider/PlayerProviderBootTest.java b/common/src/test/java/com/discordsrv/common/player/provider/PlayerProviderBootTest.java index d95d5eaf..41a946e5 100644 --- a/common/src/test/java/com/discordsrv/common/player/provider/PlayerProviderBootTest.java +++ b/common/src/test/java/com/discordsrv/common/player/provider/PlayerProviderBootTest.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.common.player.provider; import com.discordsrv.common.FullBootExtension; diff --git a/common/unrelocate/src/main/java/com/discordsrv/unrelocate/net/kyori/adventure/text/Component.java b/common/unrelocate/src/main/java/com/discordsrv/unrelocate/net/kyori/adventure/text/Component.java index bc8dc002..56595127 100644 --- a/common/unrelocate/src/main/java/com/discordsrv/unrelocate/net/kyori/adventure/text/Component.java +++ b/common/unrelocate/src/main/java/com/discordsrv/unrelocate/net/kyori/adventure/text/Component.java @@ -1,3 +1,21 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2024 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 . + */ + package com.discordsrv.unrelocate.net.kyori.adventure.text; @SuppressWarnings("NonExtendableApiUsage") diff --git a/common/unrelocate/src/main/java/com/discordsrv/unrelocate/org/slf4j/Logger.java b/common/unrelocate/src/main/java/com/discordsrv/unrelocate/org/slf4j/Logger.java index 360a1567..11679ce2 100644 --- a/common/unrelocate/src/main/java/com/discordsrv/unrelocate/org/slf4j/Logger.java +++ b/common/unrelocate/src/main/java/com/discordsrv/unrelocate/org/slf4j/Logger.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c1962a79..e6441136 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8707e8b5..a4413138 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index aeb74cbb..b740cf13 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -83,7 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -130,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -198,11 +202,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index 93e3f59f..25da30db 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/i18n/src/main/java/com/discordsrv/config/DiscordSRVTranslation.java b/i18n/src/main/java/com/discordsrv/config/DiscordSRVTranslation.java index 1a1dfd6a..55933e99 100644 --- a/i18n/src/main/java/com/discordsrv/config/DiscordSRVTranslation.java +++ b/i18n/src/main/java/com/discordsrv/config/DiscordSRVTranslation.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/i18n/src/main/java/com/discordsrv/config/TranslationConfigManagerProxy.java b/i18n/src/main/java/com/discordsrv/config/TranslationConfigManagerProxy.java index b055a710..a0bf8dec 100644 --- a/i18n/src/main/java/com/discordsrv/config/TranslationConfigManagerProxy.java +++ b/i18n/src/main/java/com/discordsrv/config/TranslationConfigManagerProxy.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/settings.gradle b/settings.gradle index c5d7eab4..b29b884f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,10 +10,12 @@ dependencyResolutionManagement { versionCatalogs { libs { // Buildscript - plugin('shadow', 'com.github.johnrengelman.shadow').version('8.1.1') - plugin('licenser', 'org.cadixdev.licenser').version('0.6.1') - plugin('blossom', 'net.kyori.blossom').version('1.2.0') - plugin('indra-git', 'net.kyori.indra.git').version('2.1.1') + plugin('shadow', 'io.github.goooler.shadow').version('8.1.7') + plugin('spotless', 'com.diffplug.spotless').version('6.25.0') + plugin('blossom', 'net.kyori.blossom').version('2.1.0') + plugin('indra-git', 'net.kyori.indra.git').version('2.2.0') + plugin('indra-licenser', 'net.kyori.indra.licenser.spotless').version('2.2.0') + plugin('idea-ext', 'org.jetbrains.gradle.plugin.idea-ext').version('1.1.7') // Bukkit version('bukkit_minimum', '1.8.8-R0.1-SNAPSHOT') @@ -127,16 +129,14 @@ dependencyResolutionManagement { library('adventure-serializer-bungee', 'net.kyori', 'adventure-text-serializer-bungeecord').versionRef('adventure-platform') // Upgrade ansi (used by ansi serializer) - library('kyori-ansi', 'net.kyori', 'ansi').version('1.1.0-SNAPSHOT') + library('kyori-ansi', 'net.kyori', 'ansi').version('1.1.0') // MCDiscordReserializer & EnhancedLegacyText library('mcdiscordreserializer', 'dev.vankka', 'mcdiscordreserializer').version('4.4.0-SNAPSHOT') library('enhancedlegacytext', 'dev.vankka', 'enhancedlegacytext').version('2.0.0-SNAPSHOT') // JUnit - version('junit', '5.10.0') - library('jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit') - library('jupiter-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit') + library('junit-jupiter', 'org.junit.jupiter', 'junit-jupiter').version('5.10.2') } } } diff --git a/velocity/build.gradle b/velocity/build.gradle index 3db928c9..febea034 100644 --- a/velocity/build.gradle +++ b/velocity/build.gradle @@ -1,5 +1,16 @@ apply from: rootProject.file('buildscript/standalone.gradle') apply plugin: 'net.kyori.blossom' +apply plugin: 'org.jetbrains.gradle.plugin.idea-ext' + +sourceSets { + main { + blossom { + javaSources { + property('version', project.version.toString()) + } + } + } +} shadowJar { archiveBaseName = 'DiscordSRV-Velocity' @@ -32,13 +43,4 @@ dependencies { // DependencyDownload implementation(libs.mcdependencydownload.velocity) -} - -jar { - dependsOn blossomSourceReplacementJava -} - -blossom { - var mainClass = 'src/main/java/com/discordsrv/velocity/DiscordSRVVelocityBootstrap.java' - replaceToken('@VERSION@', project.version, mainClass) -} +} \ No newline at end of file diff --git a/velocity/src/main/java-templates/com/discordsrv/velocity/Constants.java.peb b/velocity/src/main/java-templates/com/discordsrv/velocity/Constants.java.peb new file mode 100644 index 00000000..f966e241 --- /dev/null +++ b/velocity/src/main/java-templates/com/discordsrv/velocity/Constants.java.peb @@ -0,0 +1,8 @@ +package com.discordsrv.velocity; + +public final class Constants { + private Constants() {} + +{# @pebvariable name="version" type="java.lang.String" #} + public static final String VERSION = "{{ version }}"; +} \ No newline at end of file diff --git a/velocity/src/main/java/com/discordsrv/velocity/DiscordSRVVelocityBootstrap.java b/velocity/src/main/java/com/discordsrv/velocity/DiscordSRVVelocityBootstrap.java index 33bcc3a0..799d476f 100644 --- a/velocity/src/main/java/com/discordsrv/velocity/DiscordSRVVelocityBootstrap.java +++ b/velocity/src/main/java/com/discordsrv/velocity/DiscordSRVVelocityBootstrap.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 @@ -41,7 +41,7 @@ import java.nio.file.Path; @Plugin( id = "discordsrv", name = "DiscordSRV", - version = "@VERSION@", + version = Constants.VERSION, description = "", authors = {"Scarsz", "Vankka"}, url = DiscordSRV.WEBSITE diff --git a/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java b/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java index e646437d..53c0affd 100644 --- a/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java +++ b/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/velocity/src/main/java/com/discordsrv/velocity/command/game/handler/VelocityCommandHandler.java b/velocity/src/main/java/com/discordsrv/velocity/command/game/handler/VelocityCommandHandler.java index 98ce02da..16982e3f 100644 --- a/velocity/src/main/java/com/discordsrv/velocity/command/game/handler/VelocityCommandHandler.java +++ b/velocity/src/main/java/com/discordsrv/velocity/command/game/handler/VelocityCommandHandler.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/velocity/src/main/java/com/discordsrv/velocity/command/game/sender/VelocityCommandSender.java b/velocity/src/main/java/com/discordsrv/velocity/command/game/sender/VelocityCommandSender.java index 820db2b7..98427a56 100644 --- a/velocity/src/main/java/com/discordsrv/velocity/command/game/sender/VelocityCommandSender.java +++ b/velocity/src/main/java/com/discordsrv/velocity/command/game/sender/VelocityCommandSender.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/velocity/src/main/java/com/discordsrv/velocity/console/VelocityConsole.java b/velocity/src/main/java/com/discordsrv/velocity/console/VelocityConsole.java index d2e6b455..784d85e5 100644 --- a/velocity/src/main/java/com/discordsrv/velocity/console/VelocityConsole.java +++ b/velocity/src/main/java/com/discordsrv/velocity/console/VelocityConsole.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/velocity/src/main/java/com/discordsrv/velocity/console/executor/VelocityCommandExecutor.java b/velocity/src/main/java/com/discordsrv/velocity/console/executor/VelocityCommandExecutor.java index ef234273..a3d7eaff 100644 --- a/velocity/src/main/java/com/discordsrv/velocity/console/executor/VelocityCommandExecutor.java +++ b/velocity/src/main/java/com/discordsrv/velocity/console/executor/VelocityCommandExecutor.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/velocity/src/main/java/com/discordsrv/velocity/console/executor/VelocityCommandExecutorProvider.java b/velocity/src/main/java/com/discordsrv/velocity/console/executor/VelocityCommandExecutorProvider.java index 081a0f4c..09d3346c 100644 --- a/velocity/src/main/java/com/discordsrv/velocity/console/executor/VelocityCommandExecutorProvider.java +++ b/velocity/src/main/java/com/discordsrv/velocity/console/executor/VelocityCommandExecutorProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/velocity/src/main/java/com/discordsrv/velocity/player/VelocityPlayer.java b/velocity/src/main/java/com/discordsrv/velocity/player/VelocityPlayer.java index b82cb497..3686909c 100644 --- a/velocity/src/main/java/com/discordsrv/velocity/player/VelocityPlayer.java +++ b/velocity/src/main/java/com/discordsrv/velocity/player/VelocityPlayer.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/velocity/src/main/java/com/discordsrv/velocity/player/VelocityPlayerProvider.java b/velocity/src/main/java/com/discordsrv/velocity/player/VelocityPlayerProvider.java index 4d10a89a..435fdab3 100644 --- a/velocity/src/main/java/com/discordsrv/velocity/player/VelocityPlayerProvider.java +++ b/velocity/src/main/java/com/discordsrv/velocity/player/VelocityPlayerProvider.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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 diff --git a/velocity/src/main/java/com/discordsrv/velocity/plugin/VelocityPluginManager.java b/velocity/src/main/java/com/discordsrv/velocity/plugin/VelocityPluginManager.java index d9180404..1e4ee221 100644 --- a/velocity/src/main/java/com/discordsrv/velocity/plugin/VelocityPluginManager.java +++ b/velocity/src/main/java/com/discordsrv/velocity/plugin/VelocityPluginManager.java @@ -1,6 +1,6 @@ /* * This file is part of DiscordSRV, licensed under the GPLv3 License - * Copyright (c) 2016-2023 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * Copyright (c) 2016-2024 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