diff --git a/build.gradle b/build.gradle index 8362927..aeac22f 100644 --- a/build.gradle +++ b/build.gradle @@ -8,13 +8,19 @@ plugins { alias(libs.plugins.lombok) } -def baseVersion = "4.0.4" +wrapper { + gradleVersion = '8.1.1' +} + +def baseVersion = "4.0.7" def isSnapshot = false version = (isSnapshot) ? baseVersion + '-SNAPSHOT' : baseVersion group = 'io.github.readonly' archivesBaseName = 'JDATools' +dependencyUpdates.gradleReleaseChannel="current" + java { withJavadocJar() withSourcesJar() @@ -28,7 +34,7 @@ repositories { dependencies { api(libs.jda) { exclude module: 'opus-java' } implementation libs.json - api libs.slf4j + compileOnly libs.slf4j api libs.guava api libs.guice api libs.commons.lang3 @@ -42,11 +48,10 @@ license { include '**/*.java' } -compileJava.options.encoding = 'UTF-8' - -tasks.withType(JavaCompile) { - options.encoding = 'UTF-8' - classpath += sourceSets.main.compileClasspath +tasks.withType(JavaCompile).configureEach { + classpath += sourceSets.main.compileClasspath + options.deprecation = true + options.encoding = 'UTF-8' } javadoc { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3dcbdc1..d6b806a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,17 +3,17 @@ version = "1.0" [versions] -jda = "5.0.0-beta.8" -json = "20220320" +jda = "5.0.0-beta.10" +json = "20230227" lang3 = "3.12.0" -jackson = "2.14.1" +jackson = "2.15.2" lombok = "1.18.24" -guava = "31.1-jre" -guice = "5.1.0" -slf4j = "1.7.32" +guava = "32.0.0-jre" +guice = "7.0.0" +slf4j = "1.7.36" licenser = "0.6.1" lombokplugin = "8.0.1" -versionsPlugin = "0.42.0" +versionsPlugin = "0.46.0" [libraries] json = { module = "org.json:json", version.ref = "json" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..c1962a7 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 aa991fc..37aef8d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index c53aefa..aeb74cb 100644 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright � 2015-2021 the original authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; -# * expansions �$var�, �${var}�, �${var:-default}�, �${var+SET}�, -# �${var#prefix}�, �${var%suffix}�, and �$( cmd )�; -# * compound commands having a testable exit status, especially �case�; -# * various built-in commands including �command�, �set�, and �ulimit�. +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# 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"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -143,12 +140,16 @@ fi 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 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then done 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 @@ -205,6 +210,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd3..93e3f59 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/src/main/java/io/github/readonly/Properties.java b/src/main/java/io/github/readonly/Properties.java index aee3086..1a996ae 100644 --- a/src/main/java/io/github/readonly/Properties.java +++ b/src/main/java/io/github/readonly/Properties.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly; public class Properties diff --git a/src/main/java/io/github/readonly/api/BotContainer.java b/src/main/java/io/github/readonly/api/BotContainer.java index dbb240b..b210f7d 100644 --- a/src/main/java/io/github/readonly/api/BotContainer.java +++ b/src/main/java/io/github/readonly/api/BotContainer.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.api; import java.util.Optional; @@ -42,7 +66,9 @@ default Optional getVersion() { * * @return The instance if available */ - Optional getInstance(); + default Optional getInstance() { + return Optional.empty(); + } /** * Returns the assigned logger to this {@link Bot}. diff --git a/src/main/java/io/github/readonly/api/ClientInterface.java b/src/main/java/io/github/readonly/api/ClientInterface.java index 782a284..92d8595 100644 --- a/src/main/java/io/github/readonly/api/ClientInterface.java +++ b/src/main/java/io/github/readonly/api/ClientInterface.java @@ -248,7 +248,7 @@ default void addCommands(Command... commands) * @throws java.lang.IllegalArgumentException * If the Context Menu provided has a name that has already been registered */ - void addContextMenu(ContextMenu menu); + void indexContextMenu(ContextMenu menu); /** * Adds a single {@link ContextMenu} to this CommandClient's registered Context Menus. @@ -261,7 +261,7 @@ default void addCommands(Command... commands) * @throws java.lang.IllegalArgumentException * If the Context Menu provided has a name that has already been registered */ - void addContextMenu(ContextMenu menu, int index); + void indexContextMenu(ContextMenu menu, int index); /** * Removes a single {@link io.github.readonly.command.Command Command} from this Client's registered Commands at the diff --git a/src/main/java/io/github/readonly/api/identity/Bot.java b/src/main/java/io/github/readonly/api/identity/Bot.java index cb1137f..7453f2b 100644 --- a/src/main/java/io/github/readonly/api/identity/Bot.java +++ b/src/main/java/io/github/readonly/api/identity/Bot.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.api.identity; public interface Bot extends Identifiable diff --git a/src/main/java/io/github/readonly/api/identity/Identifiable.java b/src/main/java/io/github/readonly/api/identity/Identifiable.java index b0fd0eb..cd9fef4 100644 --- a/src/main/java/io/github/readonly/api/identity/Identifiable.java +++ b/src/main/java/io/github/readonly/api/identity/Identifiable.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.api.identity; import java.util.UUID; diff --git a/src/main/java/io/github/readonly/api/identity/Nameable.java b/src/main/java/io/github/readonly/api/identity/Nameable.java index 9e65af2..e0566a2 100644 --- a/src/main/java/io/github/readonly/api/identity/Nameable.java +++ b/src/main/java/io/github/readonly/api/identity/Nameable.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.api.identity; public interface Nameable extends Identifiable diff --git a/src/main/java/io/github/readonly/api/rmi/Group.java b/src/main/java/io/github/readonly/api/rmi/Group.java index 85e207f..f4a87c9 100644 --- a/src/main/java/io/github/readonly/api/rmi/Group.java +++ b/src/main/java/io/github/readonly/api/rmi/Group.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.api.rmi; import java.io.Serializable; diff --git a/src/main/java/io/github/readonly/api/rmi/RMIConnector.java b/src/main/java/io/github/readonly/api/rmi/RMIConnector.java index a40041f..d9dc0fa 100644 --- a/src/main/java/io/github/readonly/api/rmi/RMIConnector.java +++ b/src/main/java/io/github/readonly/api/rmi/RMIConnector.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.api.rmi; import java.rmi.Remote; diff --git a/src/main/java/io/github/readonly/api/rmi/RamUsage.java b/src/main/java/io/github/readonly/api/rmi/RamUsage.java index 25270a1..a1efb97 100644 --- a/src/main/java/io/github/readonly/api/rmi/RamUsage.java +++ b/src/main/java/io/github/readonly/api/rmi/RamUsage.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.api.rmi; import java.io.Serializable; diff --git a/src/main/java/io/github/readonly/api/rmi/StatusListener.java b/src/main/java/io/github/readonly/api/rmi/StatusListener.java index 805526c..006eeb6 100644 --- a/src/main/java/io/github/readonly/api/rmi/StatusListener.java +++ b/src/main/java/io/github/readonly/api/rmi/StatusListener.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.api.rmi; import java.lang.instrument.Instrumentation; diff --git a/src/main/java/io/github/readonly/api/rmi/ThreadInfo.java b/src/main/java/io/github/readonly/api/rmi/ThreadInfo.java index 089e53e..4bbc167 100644 --- a/src/main/java/io/github/readonly/api/rmi/ThreadInfo.java +++ b/src/main/java/io/github/readonly/api/rmi/ThreadInfo.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.api.rmi; import java.io.Serializable; diff --git a/src/main/java/io/github/readonly/api/scheduler/ITask.java b/src/main/java/io/github/readonly/api/scheduler/ITask.java index eeba6d9..7ec17b5 100644 --- a/src/main/java/io/github/readonly/api/scheduler/ITask.java +++ b/src/main/java/io/github/readonly/api/scheduler/ITask.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.api.scheduler; import java.util.concurrent.TimeUnit; diff --git a/src/main/java/io/github/readonly/api/scheduler/Scheduler.java b/src/main/java/io/github/readonly/api/scheduler/Scheduler.java index 26b0915..6658e6b 100644 --- a/src/main/java/io/github/readonly/api/scheduler/Scheduler.java +++ b/src/main/java/io/github/readonly/api/scheduler/Scheduler.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.api.scheduler; import java.util.Optional; diff --git a/src/main/java/io/github/readonly/api/scheduler/TaskService.java b/src/main/java/io/github/readonly/api/scheduler/TaskService.java index 0c8f3fe..089c86b 100644 --- a/src/main/java/io/github/readonly/api/scheduler/TaskService.java +++ b/src/main/java/io/github/readonly/api/scheduler/TaskService.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.api.scheduler; import java.util.concurrent.Callable; diff --git a/src/main/java/io/github/readonly/api/util/ResettableBuilder.java b/src/main/java/io/github/readonly/api/util/ResettableBuilder.java index 9b15737..98b813c 100644 --- a/src/main/java/io/github/readonly/api/util/ResettableBuilder.java +++ b/src/main/java/io/github/readonly/api/util/ResettableBuilder.java @@ -1,8 +1,7 @@ /* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * This file is part of JDATools, licensed under the MIT License (MIT). * - * Copyright (c) SpongePowered - * Copyright (c) contributors + * Copyright (c) ROMVoid95 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + package io.github.readonly.api.util; /** diff --git a/src/main/java/io/github/readonly/command/Client.java b/src/main/java/io/github/readonly/command/Client.java index 1e13ad7..01700ba 100644 --- a/src/main/java/io/github/readonly/command/Client.java +++ b/src/main/java/io/github/readonly/command/Client.java @@ -130,7 +130,8 @@ public class Client implements ClientInterface, EventListener private final ScheduledExecutorService executor; private final GuildSettingsManager manager; - private final LinkedList globalCommands; + private final LinkedList globalSlashCommands; + private final LinkedList globalUserInteractions; private final LinkedList totalSlashCommands; private final HashMap slashCommandIndex; @@ -154,8 +155,8 @@ public Client( BiFunction commandPreProcessBiFunction, Activity activity, OnlineStatus status, String serverInvite, String success, String warning, String error, ArrayList commands, - ArrayList contextMenus, LinkedList serverCommands, - LinkedList globalSlashCommands, boolean embedAllReplies, + LinkedList serverCommands, LinkedList slashCommands, + LinkedList userInteractions, boolean embedAllReplies, boolean useHelp, boolean shutdownAutomatically, Consumer helpConsumer, String helpWord, ScheduledExecutorService executor, int linkedCacheSize, GuildSettingsManager manager ) @@ -211,7 +212,8 @@ public Client( this.slashCommandIndex = new HashMap<>(); this.totalContextMenus = new LinkedList<>(); this.contextMenuIndex = new HashMap<>(); - this.globalCommands = new LinkedList<>(); + this.globalSlashCommands = new LinkedList<>(); + this.globalUserInteractions = new LinkedList<>(); this.commands = new ArrayList<>(); this.categoryToCommandListMap = new HashMap<>(); this.categoryToCommandListMap.put(new Category("Uncategorized"), new ArrayList<>()); @@ -245,7 +247,7 @@ public Client( User owner = event.getJDA().getUserById(ownerId); if (owner != null) { - builder.append("\n\nFor additional help, contact **").append(owner.getName()).append("**#").append(owner.getDiscriminator()); + builder.append("\n\nFor additional help, contact **").append(owner.getName()); if (serverInvite != null) { builder.append(" or join ").append(serverInvite); @@ -269,16 +271,16 @@ public Client( addCommand(command); } // Load GlobalSlashCommands commands - for (SlashCommand command : globalSlashCommands) + for (SlashCommand command : slashCommands) { indexSlashCommand(command); - globalCommands.add(command); + globalSlashCommands.add(command); } - // Load context menus - for (ContextMenu menu : contextMenus) + for(ContextMenu ctxMenu : userInteractions) { - addContextMenu(menu); + indexContextMenu(ctxMenu); + globalUserInteractions.add(ctxMenu); } for (ServerCommands serverCmds : serverCommands) @@ -292,7 +294,7 @@ public Client( for (ContextMenu serverMenus : serverCmds.getContextMenus()) { - addContextMenu(serverMenus); + indexContextMenu(serverMenus); } } } @@ -324,7 +326,7 @@ public List getServerCommands() @Override public List getGlobalSlashCommands() { - return globalCommands; + return globalSlashCommands; } @Override @@ -488,13 +490,13 @@ public void indexSlashCommand(SlashCommand command) } @Override - public void addContextMenu(ContextMenu menu) + public void indexContextMenu(ContextMenu menu) { - addContextMenu(menu, totalContextMenus.size()); + indexContextMenu(menu, totalContextMenus.size()); } @Override - public void addContextMenu(ContextMenu menu, int index) + public void indexContextMenu(ContextMenu menu, int index) { if ((index > totalContextMenus.size()) || (index < 0)) { @@ -769,7 +771,7 @@ public void upsertServerCommands(JDA jda) { //@noformat guild.updateCommands().addCommands(data).queue( - priv -> LOG.info("Successfully added " + server.getSlashCommands().size() + " slash commands and " + server.getContextMenus().size() + " menus to server " + guild.getName()), + priv -> LOG.info("Successfully added " + server.getSlashCommands().size() + " slash commands and " + server.getContextMenus().size() + "context menus to server " + guild.getName()), error -> LOG.error("Could not upsert commands! Does the bot have the applications.commands scope?" + error)); //@format } @@ -780,12 +782,17 @@ public void upsertGlobalSlashCommands(JDA jda) { // Get all commands List data = new ArrayList<>(); - for (SlashCommand cmd : globalCommands) + for (SlashCommand cmd : globalSlashCommands) { data.add(cmd.build()); } - jda.updateCommands().addCommands(data).queue(commands -> LOG.info("Successfully added " + globalCommands.size() + " global slash commands!")); + for (ContextMenu ctx : globalUserInteractions) + { + data.add(ctx.build()); + } + + jda.updateCommands().addCommands(data).queue(commands -> LOG.info("Successfully added " + globalSlashCommands.size() + " global slash commands and" + globalUserInteractions.size() + "context menus")); } private void onMessageReceived(MessageReceivedEvent event) diff --git a/src/main/java/io/github/readonly/command/ClientBuilder.java b/src/main/java/io/github/readonly/command/ClientBuilder.java index 74f96ea..a633996 100644 --- a/src/main/java/io/github/readonly/command/ClientBuilder.java +++ b/src/main/java/io/github/readonly/command/ClientBuilder.java @@ -66,9 +66,9 @@ public class ClientBuilder private String warning; private String error; private final LinkedList commands = new LinkedList<>(); - private final LinkedList contextMenus = new LinkedList<>(); private final LinkedList serverCommands = new LinkedList<>(); private final LinkedList globalSlashCommands = new LinkedList<>(); + private final LinkedList globalUserInteractions = new LinkedList<>(); final HashMap> categoryToCommandListMap = new LinkedHashMap>(); private boolean embedAllReplies = false; private CommandListener listener; @@ -95,8 +95,8 @@ public Client build() prefixFunction, commandPreProcessFunction, commandPreProcessBiFunction, activity, status, serverInvite, success, warning, error, - new ArrayList<>(commands), new ArrayList<>(contextMenus), - serverCommands, globalSlashCommands, embedAllReplies, + new ArrayList<>(commands), serverCommands, + globalSlashCommands, globalUserInteractions, embedAllReplies, useHelp, shutdownAutomatically, helpConsumer, helpWord, executor, linkedCacheSize, manager ); @@ -471,7 +471,7 @@ public ClientBuilder addGlobalSlashCommands(Collection slashComman */ public ClientBuilder addContextMenu(ContextMenu contextMenu) { - contextMenus.add(contextMenu); + globalUserInteractions.add(contextMenu); return this; } diff --git a/src/main/java/io/github/readonly/command/DirectMessageSlashCommand.java b/src/main/java/io/github/readonly/command/DirectMessageSlashCommand.java index 24efca6..8677f42 100644 --- a/src/main/java/io/github/readonly/command/DirectMessageSlashCommand.java +++ b/src/main/java/io/github/readonly/command/DirectMessageSlashCommand.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.command; import io.github.readonly.command.event.SlashCommandEvent; diff --git a/src/main/java/io/github/readonly/command/DiscordInfo.java b/src/main/java/io/github/readonly/command/DiscordInfo.java new file mode 100644 index 0000000..f2b8d81 --- /dev/null +++ b/src/main/java/io/github/readonly/command/DiscordInfo.java @@ -0,0 +1,18 @@ +package io.github.readonly.command; + +import lombok.Data; +import net.dv8tion.jda.api.entities.User; + +@Data +public class DiscordInfo { + private String username; + private String id; + + public static DiscordInfo of(User user) + { + var info = new DiscordInfo(); + info.setId(user.getId()); + info.setUsername(user.getName()); + return info; + } +} \ No newline at end of file diff --git a/src/main/java/io/github/readonly/command/event/SlashCommandEvent.java b/src/main/java/io/github/readonly/command/event/SlashCommandEvent.java index 3b0581a..967370f 100644 --- a/src/main/java/io/github/readonly/command/event/SlashCommandEvent.java +++ b/src/main/java/io/github/readonly/command/event/SlashCommandEvent.java @@ -30,6 +30,7 @@ import org.jetbrains.annotations.NotNull; import io.github.readonly.command.Client; +import io.github.readonly.command.DiscordInfo; import io.github.readonly.settings.GuildSettingsManager; import net.dv8tion.jda.api.entities.IMentionable; import net.dv8tion.jda.api.entities.Member; @@ -45,13 +46,20 @@ public class SlashCommandEvent extends SlashCommandInteractionEvent implements Event { private final Client client; + private final DiscordInfo info; public SlashCommandEvent(SlashCommandInteractionEvent event, Client client) { super(event.getJDA(), event.getResponseNumber(), event); + this.info = DiscordInfo.of(event.getUser()); this.client = client; } + public DiscordInfo getInfo() + { + return info; + } + /** * The {@link Client} that this event was triggered from. * diff --git a/src/main/java/io/github/readonly/command/included/CommandGuildlist.java b/src/main/java/io/github/readonly/command/included/CommandGuildlist.java index 8461805..d01b131 100644 --- a/src/main/java/io/github/readonly/command/included/CommandGuildlist.java +++ b/src/main/java/io/github/readonly/command/included/CommandGuildlist.java @@ -102,7 +102,7 @@ static JoinedServerEmbed func() public MessageEmbed apply(Guild g) { embed.setTitle(g.getName(), g.getIconUrl()); - embed.setDescription(format("Owner", g.getOwner().getUser().getAsTag())); + embed.setDescription(format("Owner", g.getOwner().getUser().getName())); embed.appendDescription(format("Members", g.getMemberCount())); embed.appendDescription(format("Created", time(g.getTimeCreated()))); embed.setThumbnail(g.getIconUrl()).build(); diff --git a/src/main/java/io/github/readonly/command/lists/ChoiceList.java b/src/main/java/io/github/readonly/command/lists/ChoiceList.java index 1e3a2d3..b65c7fb 100644 --- a/src/main/java/io/github/readonly/command/lists/ChoiceList.java +++ b/src/main/java/io/github/readonly/command/lists/ChoiceList.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.command.lists; import java.util.ArrayList; diff --git a/src/main/java/io/github/readonly/command/lists/OptionsList.java b/src/main/java/io/github/readonly/command/lists/OptionsList.java index d45a6f3..8b1fd13 100644 --- a/src/main/java/io/github/readonly/command/lists/OptionsList.java +++ b/src/main/java/io/github/readonly/command/lists/OptionsList.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.command.lists; import java.util.ArrayList; diff --git a/src/main/java/io/github/readonly/command/option/Choice.java b/src/main/java/io/github/readonly/command/option/Choice.java index 07c37c6..b6e9f6b 100644 --- a/src/main/java/io/github/readonly/command/option/Choice.java +++ b/src/main/java/io/github/readonly/command/option/Choice.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.command.option; import net.dv8tion.jda.api.interactions.commands.Command; diff --git a/src/main/java/io/github/readonly/command/option/Opt.java b/src/main/java/io/github/readonly/command/option/Opt.java index f4dbdeb..abc995b 100644 --- a/src/main/java/io/github/readonly/command/option/Opt.java +++ b/src/main/java/io/github/readonly/command/option/Opt.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.command.option; public abstract class Opt diff --git a/src/main/java/io/github/readonly/command/option/Option.java b/src/main/java/io/github/readonly/command/option/Option.java index 2ab4a4e..6c4aef5 100644 --- a/src/main/java/io/github/readonly/command/option/Option.java +++ b/src/main/java/io/github/readonly/command/option/Option.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.command.option; import javax.annotation.Nonnull; diff --git a/src/main/java/io/github/readonly/command/option/RequiredOption.java b/src/main/java/io/github/readonly/command/option/RequiredOption.java index a4ab8cb..f4e3a53 100644 --- a/src/main/java/io/github/readonly/command/option/RequiredOption.java +++ b/src/main/java/io/github/readonly/command/option/RequiredOption.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.command.option; import javax.annotation.Nonnull; diff --git a/src/main/java/io/github/readonly/common/event/EventHandler.java b/src/main/java/io/github/readonly/common/event/EventHandler.java index 6cfd688..2a79f19 100644 --- a/src/main/java/io/github/readonly/common/event/EventHandler.java +++ b/src/main/java/io/github/readonly/common/event/EventHandler.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.event; import com.google.common.eventbus.EventBus; diff --git a/src/main/java/io/github/readonly/common/event/JDAToolsEvent.java b/src/main/java/io/github/readonly/common/event/JDAToolsEvent.java index 5f9aafb..d92a6c6 100644 --- a/src/main/java/io/github/readonly/common/event/JDAToolsEvent.java +++ b/src/main/java/io/github/readonly/common/event/JDAToolsEvent.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.event; public interface JDAToolsEvent diff --git a/src/main/java/io/github/readonly/common/event/jda/JDAEvent.java b/src/main/java/io/github/readonly/common/event/jda/JDAEvent.java index ea5b651..cf4e475 100644 --- a/src/main/java/io/github/readonly/common/event/jda/JDAEvent.java +++ b/src/main/java/io/github/readonly/common/event/jda/JDAEvent.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.event.jda; import io.github.readonly.common.event.JDAToolsEvent; diff --git a/src/main/java/io/github/readonly/common/event/jda/PostReadyEvent.java b/src/main/java/io/github/readonly/common/event/jda/PostReadyEvent.java index 2a605f5..314f02b 100644 --- a/src/main/java/io/github/readonly/common/event/jda/PostReadyEvent.java +++ b/src/main/java/io/github/readonly/common/event/jda/PostReadyEvent.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.event.jda; import net.dv8tion.jda.api.events.session.ReadyEvent; diff --git a/src/main/java/io/github/readonly/common/util/FinderUtil.java b/src/main/java/io/github/readonly/common/util/FinderUtil.java deleted file mode 100644 index f7168e0..0000000 --- a/src/main/java/io/github/readonly/common/util/FinderUtil.java +++ /dev/null @@ -1,1061 +0,0 @@ -/* - * This file is part of JDATools, licensed under the MIT License (MIT). - * - * Copyright (c) ROMVoid95 - * - * 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 io.github.readonly.common.util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -import net.dv8tion.jda.api.JDA; -import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.Role; -import net.dv8tion.jda.api.entities.User; -import net.dv8tion.jda.api.entities.channel.concrete.Category; -import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; -import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel; -import net.dv8tion.jda.api.entities.emoji.Emoji; -import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji; -import net.dv8tion.jda.api.sharding.ShardManager; -import net.dv8tion.jda.api.utils.cache.SnowflakeCacheView; - -/** - * A series of query based utilities for finding entities, either globally across all accessible - * {@link net.dv8tion.jda.api.entities.Guild Guild}s, or locally to a specified Guild. - *

- * All methods use a similar priority hierarchy and return an immutable {@link java.util.List List} based on the - * results.
- * The hierarchy is as follows: - *

    - *
  • Special Cases: Specifics of these are described per individual method documentation.
    - * Note that successful results from these are typically {@link java.util.Collections#singletonList(Object) a singleton - * list}.
  • - *
  • Direct ID: Query is a number with 17 or more digits, resembling an {@link net.dv8tion.jda.api.entities.ISnowflake - * ISnowflake} ID.
  • - *
  • Exact Match: Query provided is an exact match (case sensitive and complete) to one or more entities.
  • - *
  • Wrong Case: Query provided is a case-insensitive, but exact, match to the entirety of one or more entities.
  • - *
  • Starting With: Query provided is an case-insensitive match to the beginning of one or more entities.
  • - *
  • Contains: Query provided is a case-insensitive match to a part of one or more entities.
  • - *
- * All queries return the highest List in this hierarchy that contains one or more entities, and only of these kind of - * results (IE: the "exact" list will never contain any results from a successful "starting with" match, unless by - * chance they could technically be the same result). - *

- * Shard Manager Usage
- * Methods that query an instance of {@link net.dv8tion.jda.api.JDA JDA} always have two implementations: - *

    - *
  • Global: Queries a {@link net.dv8tion.jda.api.sharding.ShardManager ShardManager} if one is available, or - * JDA if one is not.
  • - *
  • Shard: Always queries the provided instance, and never a ShardManager, even if one is available.
  • - *
- */ -public final class FinderUtil -{ - public final static Pattern DISCORD_ID = Pattern.compile("\\d{17,20}"); // ID - public final static Pattern FULL_USER_REF = Pattern.compile("(\\S.{0,30}\\S)\\s*#(\\d{4})"); // $1 - // -> - // username, - // $2 - // -> discriminator - public final static Pattern USER_MENTION = Pattern.compile("<@!?(\\d{17,20})>"); // $1 - // -> - // ID - public final static Pattern CHANNEL_MENTION = Pattern.compile("<#(\\d{17,20})>"); // $1 - // -> - // ID - public final static Pattern ROLE_MENTION = Pattern.compile("<@&(\\d{17,20})>"); // $1 - // -> - // ID - public final static Pattern Emoji_MENTION = Pattern.compile("<:(.{2,32}):(\\d{17,20})>"); - - /** - * Queries a provided instance of {@link net.dv8tion.jda.api.JDA JDA} for {@link net.dv8tion.jda.api.entities.User - * User}s. - *

- * If a {@link net.dv8tion.jda.api.sharding.ShardManager ShardManager} is available this will query across that - * instead of the JDA instance. - *

- * The following special cases are applied in order of listing before the standard search is done: - *

    - *
  • User Mention: Query provided matches an @user mention (more specifically {@literal <@userID>}).
  • - *
  • Full User Reference: Query provided matches a full Username#XXXX reference.
    - * NOTE: this can return a list with more than one entity.
  • - *
- * - * @param query - * The String query to search by - * @param jda - * The instance of JDA to search from - * - * @return A possibly-empty {@link java.util.List List} of Users found by the query from the provided JDA instance. - */ - public static List findUsers(String query, JDA jda) - { - return jdaUserSearch(query, jda, true); - } - - /** - * Queries a provided instance of {@link net.dv8tion.jda.api.JDA JDA} for {@link net.dv8tion.jda.api.entities.User - * User}s. - *

- * This only queries the instance of JDA, regardless of whether or not a - * {@link net.dv8tion.jda.api.sharding.ShardManager ShardManager} is available. - *

- * The following special cases are applied in order of listing before the standard search is done: - *

    - *
  • User Mention: Query provided matches an @user mention (more specifically {@literal <@userID>}).
  • - *
  • Full User Reference: Query provided matches a full Username#XXXX reference.
    - * NOTE: this can return a list with more than one entity.
  • - *
- * - * @param query - * The String query to search by - * @param jda - * The instance of JDA to search from - * - * @return A possibly-empty {@link java.util.List List} of Users found by the query from the provided JDA instance. - */ - public static List findShardUsers(String query, JDA jda) - { - return jdaUserSearch(query, jda, false); - } - - private static List jdaUserSearch(String query, JDA jda, boolean useShardManager) - { - Matcher userMention = USER_MENTION.matcher(query); - Matcher fullRefMatch = FULL_USER_REF.matcher(query); - - ShardManager manager = useShardManager ? jda.getShardManager() : null; - if (userMention.matches()) - { - User user = manager != null ? manager.getUserById(userMention.group(1)) : jda.getUserById(userMention.group(1)); - if (user != null) - { - return Collections.singletonList(user); - } - } else if (fullRefMatch.matches()) - { - String lowerName = fullRefMatch.group(1).toLowerCase(Locale.ROOT); - String discrim = fullRefMatch.group(2); - List users = (manager != null ? manager.getUserCache() : jda.getUserCache()).stream().filter(user -> user.getName().toLowerCase(Locale.ROOT).equals(lowerName) && user.getDiscriminator().equals(discrim)).collect(Collectors.toList()); - if (!users.isEmpty()) - { - return users; - } - } else if (DISCORD_ID.matcher(query).matches()) - { - User user = (manager != null ? manager.getUserById(query) : jda.getUserById(query)); - if (user != null) - { - return Collections.singletonList(user); - } - } - ArrayList exact = new ArrayList<>(); - ArrayList wrongcase = new ArrayList<>(); - ArrayList startswith = new ArrayList<>(); - ArrayList contains = new ArrayList<>(); - String lowerquery = query.toLowerCase(Locale.ROOT); - (manager != null ? manager.getUserCache() : jda.getUserCache()).forEach(user -> - { - String name = user.getName(); - if (name.equals(query)) - { - exact.add(user); - } else if (name.equalsIgnoreCase(query) && exact.isEmpty()) - { - wrongcase.add(user); - } else if (name.toLowerCase(Locale.ROOT).startsWith(lowerquery) && wrongcase.isEmpty()) - { - startswith.add(user); - } else if (name.toLowerCase(Locale.ROOT).contains(lowerquery) && startswith.isEmpty()) - { - contains.add(user); - } - }); - if (!exact.isEmpty()) - { - return Collections.unmodifiableList(exact); - } - if (!wrongcase.isEmpty()) - { - return Collections.unmodifiableList(wrongcase); - } - if (!startswith.isEmpty()) - { - return Collections.unmodifiableList(startswith); - } - return Collections.unmodifiableList(contains); - } - - /** - * Queries a provided {@link net.dv8tion.jda.api.entities.Guild Guild} for a banned - * {@link net.dv8tion.jda.api.entities.User User}. - * - *

- * The following special cases are applied in order of listing before the standard search is done: - *

    - *
  • User Mention: Query provided matches an @user mention (more specifically {@literal <@userID>}).
  • - *
  • Full User Reference: Query provided matches a full Username#XXXX reference.
    - * NOTE: this can return a list with more than one entity.
  • - *
- * - *

- * WARNING - * - *

- * Unlike the other finder methods, this one has two very unique features that set it apart from the rest: - *

    - *
  • 1) In order to get a list of bans that is usable, this method initial retrieves it by usage of - * {@link net.dv8tion.jda.api.requests.RestAction#complete() Guild#getBans().complete()}. Because of this, as would - * be the same expected effect from the other utility methods, this will block the thread it is called in. The - * difference, however, comes in that this method may have slight variations in return speed, especially when put - * under higher usage over a shorter period of time.
  • - *
  • 2) This method can return {@code null} if and only if an {@link java.lang.Exception Exception} is - * thrown while initially getting banned Users via {@link net.dv8tion.jda.api.entities.Guild#retrieveBanList() - * Guild#getBanList()}.
  • - *
- * - * @param query - * The String query to search by - * @param guild - * The Guild to search for banned Users from - * - * @return A possibly-empty {@link java.util.List List} of Users found by the query from the provided JDA instance, - * or {@code null} if an {@link java.lang.Exception Exception} is thrown while initially getting banned - * Users. - * - * @see net.dv8tion.jda.api.entities.Guild#retrieveBanList() Guild#getBanList() - */ - public static List findBannedUsers(String query, Guild guild) - { - List bans; - try - { - bans = guild.retrieveBanList().complete().stream().map(Guild.Ban::getUser).collect(Collectors.toList()); - } catch (Exception e) - { - return null; - } - String discrim = null; - Matcher userMention = USER_MENTION.matcher(query); - if (userMention.matches()) - { - String id = userMention.group(1); - User user = guild.getJDA().getUserById(id); - if ((user != null) && bans.contains(user)) - { - return Collections.singletonList(user); - } - for (User u : bans) - { - if (u.getId().equals(id)) - { - return Collections.singletonList(u); - } - } - } else if (FULL_USER_REF.matcher(query).matches()) - { - discrim = query.substring(query.length() - 4); - query = query.substring(0, query.length() - 5).trim(); - } else if (DISCORD_ID.matcher(query).matches()) - { - User user = guild.getJDA().getUserById(query); - if ((user != null) && bans.contains(user)) - { - return Collections.singletonList(user); - } - for (User u : bans) - { - if (u.getId().equals(query)) - { - return Collections.singletonList(u); - } - } - } - ArrayList exact = new ArrayList<>(); - ArrayList wrongcase = new ArrayList<>(); - ArrayList startswith = new ArrayList<>(); - ArrayList contains = new ArrayList<>(); - String lowerQuery = query.toLowerCase(Locale.ROOT); - for (User u : bans) - { - // If a discrim is specified then we skip all users without it. - if ((discrim != null) && !u.getDiscriminator().equals(discrim)) - { - continue; - } - - if (u.getName().equals(query)) - { - exact.add(u); - } else if (exact.isEmpty() && u.getName().equalsIgnoreCase(query)) - { - wrongcase.add(u); - } else if (wrongcase.isEmpty() && u.getName().toLowerCase(Locale.ROOT).startsWith(lowerQuery)) - { - startswith.add(u); - } else if (startswith.isEmpty() && u.getName().toLowerCase(Locale.ROOT).contains(lowerQuery)) - { - contains.add(u); - } - } - if (!exact.isEmpty()) - { - return Collections.unmodifiableList(exact); - } - if (!wrongcase.isEmpty()) - { - return Collections.unmodifiableList(wrongcase); - } - if (!startswith.isEmpty()) - { - return Collections.unmodifiableList(startswith); - } - return Collections.unmodifiableList(contains); - } - - /** - * Queries a provided {@link net.dv8tion.jda.api.entities.Guild Guild} for - * {@link net.dv8tion.jda.api.entities.Member Member}s. - * - *

- * The following special cases are applied in order of listing before the standard search is done: - *

    - *
  • User Mention: Query provided matches an @user mention (more specifically - * {@literal <@userID> or <@!userID>}).
  • - *
  • Full User Reference: Query provided matches a full Username#XXXX reference.
    - * NOTE: this can return a list with more than one entity.
  • - *
- * - *

- * Unlike {@link FinderUtil#findUsers(String, JDA) FinderUtil.findUsers(String, JDA)}, this method queries based on - * two different names: user name and effective name (excluding special cases in which it queries solely based on - * user name).
- * Each standard check looks at the user name, then the member name, and if either one's criteria is met the Member - * is added to the returned list. This is important to note, because the returned list may contain exact matches for - * User's name as well as exact matches for a Member's effective name, with nothing guaranteeing the returns will be - * exclusively containing matches for one or the other.
- * Information on effective name can be found in {@link net.dv8tion.jda.api.entities.Member#getEffectiveName() - * Member#getEffectiveName()}. - * - * @param query - * The String query to search by - * @param guild - * The Guild to search from - * - * @return A possibly empty {@link java.util.List List} of Members found by the query from the provided Guild. - */ - public static List findMembers(String query, Guild guild) - { - Matcher userMention = USER_MENTION.matcher(query); - Matcher fullRefMatch = FULL_USER_REF.matcher(query); - if (userMention.matches()) - { - Member member = guild.getMemberById(userMention.group(1)); - if (member != null) - { - return Collections.singletonList(member); - } - } else if (fullRefMatch.matches()) - { - String lowerName = fullRefMatch.group(1).toLowerCase(Locale.ROOT); - String discrim = fullRefMatch.group(2); - List members = guild.getMemberCache().stream().filter(member -> member.getUser().getName().toLowerCase(Locale.ROOT).equals(lowerName) && member.getUser().getDiscriminator().equals(discrim)).collect(Collectors.toList()); - if (!members.isEmpty()) - { - return members; - } - } else if (DISCORD_ID.matcher(query).matches()) - { - Member member = guild.getMemberById(query); - if (member != null) - { - return Collections.singletonList(member); - } - } - ArrayList exact = new ArrayList<>(); - ArrayList wrongcase = new ArrayList<>(); - ArrayList startswith = new ArrayList<>(); - ArrayList contains = new ArrayList<>(); - String lowerquery = query.toLowerCase(Locale.ROOT); - guild.getMemberCache().forEach(member -> - { - String name = member.getUser().getName(); - String effName = member.getEffectiveName(); - if (name.equals(query) || effName.equals(query)) - { - exact.add(member); - } else if ((name.equalsIgnoreCase(query) || effName.equalsIgnoreCase(query)) && exact.isEmpty()) - { - wrongcase.add(member); - } else if ((name.toLowerCase(Locale.ROOT).startsWith(lowerquery) || effName.toLowerCase(Locale.ROOT).startsWith(lowerquery)) && wrongcase.isEmpty()) - { - startswith.add(member); - } else if ((name.toLowerCase(Locale.ROOT).contains(lowerquery) || effName.toLowerCase(Locale.ROOT).contains(lowerquery)) && startswith.isEmpty()) - { - contains.add(member); - } - }); - if (!exact.isEmpty()) - { - return Collections.unmodifiableList(exact); - } - if (!wrongcase.isEmpty()) - { - return Collections.unmodifiableList(wrongcase); - } - if (!startswith.isEmpty()) - { - return Collections.unmodifiableList(startswith); - } - return Collections.unmodifiableList(contains); - } - - /** - * Queries a provided instance of {@link net.dv8tion.jda.api.JDA JDA} for {@link net.dv8tion.jda.api.entities.channel.concrete.TextChannel - * TextChannel}s. - *

- * If a {@link net.dv8tion.jda.api.sharding.ShardManager ShardManager} is available this will query across that - * instead of the JDA instance. - *

- * The following special case is applied before the standard search is done: - *

    - *
  • Channel Mention: Query provided matches a #channel mention (more specifically {@literal <#channelID>})
  • - *
- * - * @param query - * The String query to search by - * @param jda - * The instance of JDA to search from - * - * @return A possibly-empty {@link java.util.List List} of TextChannels found by the query from the provided JDA - * instance. - */ - public static List findTextChannels(String query, JDA jda) - { - return jdaTextChannelSearch(query, jda, true); - } - - /** - * Queries a provided instance of {@link net.dv8tion.jda.api.JDA JDA} for {@link net.dv8tion.jda.api.entities.channel.concrete.TextChannel TextChannel}s.

- * - * This only queries the instance of JDA, regardless of whether or not a - * {@link net.dv8tion.jda.api.sharding.ShardManager ShardManager} is available. - * - *

The following special case is applied before the standard search is done: - *

    - *
  • Channel Mention: Query provided matches a #channel mention (more specifically {@literal <#channelID>})
  • - *
- * - * @param query - * The String query to search by - * @param jda - * The instance of JDA to search from - * - * @return A possibly-empty {@link java.util.List List} of TextChannels found by the query from the provided JDA instance. - */ - public static List findShardTextChannels(String query, JDA jda) - { - return jdaTextChannelSearch(query, jda, false); - } - - /** - * Queries a provided {@link net.dv8tion.jda.api.entities.Guild Guild} for {@link net.dv8tion.jda.api.entities.channel.concrete.TextChannel TextChannel}s. - *

- * The following special case is applied before the standard search is done: - *

    - *
  • Channel Mention: Query provided matches a #channel mention (more specifically {@literal <#channelID>})
  • - *
- * - * @param query - * The String query to search by - * @param guild - * The Guild to search from - * - * @return A possibly-empty {@link java.util.List List} of TextChannels found by the query from the provided Guild. - */ - public static List findTextChannels(String query, Guild guild) - { - Matcher channelMention = CHANNEL_MENTION.matcher(query); - if (channelMention.matches()) - { - TextChannel tc = guild.getTextChannelById(channelMention.group(1)); - if (tc != null) - { - return Collections.singletonList(tc); - } - } else if (DISCORD_ID.matcher(query).matches()) - { - TextChannel tc = guild.getTextChannelById(query); - if (tc != null) - { - return Collections.singletonList(tc); - } - } - return genericTextChannelSearch(query, guild.getTextChannelCache()); - } - - private static List jdaTextChannelSearch(String query, JDA jda, boolean useShardManager) - { - Matcher channelMention = CHANNEL_MENTION.matcher(query); - - ShardManager manager = useShardManager ? jda.getShardManager() : null; - if (channelMention.matches()) - { - TextChannel tc = manager != null ? manager.getTextChannelById(channelMention.group(1)) : jda.getTextChannelById(channelMention.group(1)); - if (tc != null) - { - return Collections.singletonList(tc); - } - } else if (DISCORD_ID.matcher(query).matches()) - { - TextChannel tc = manager != null ? manager.getTextChannelById(query) : jda.getTextChannelById(query); - if (tc != null) - { - return Collections.singletonList(tc); - } - } - return genericTextChannelSearch(query, manager != null ? manager.getTextChannelCache() : jda.getTextChannelCache()); - } - - private static List genericTextChannelSearch(String query, SnowflakeCacheView cache) - { - ArrayList exact = new ArrayList<>(); - ArrayList wrongcase = new ArrayList<>(); - ArrayList startswith = new ArrayList<>(); - ArrayList contains = new ArrayList<>(); - String lowerquery = query.toLowerCase(Locale.ROOT); - cache.forEach((tc) -> - { - String name = tc.getName(); - if (name.equals(query)) - { - exact.add(tc); - } else if (name.equalsIgnoreCase(query) && exact.isEmpty()) - { - wrongcase.add(tc); - } else if (name.toLowerCase(Locale.ROOT).startsWith(lowerquery) && wrongcase.isEmpty()) - { - startswith.add(tc); - } else if (name.toLowerCase(Locale.ROOT).contains(lowerquery) && startswith.isEmpty()) - { - contains.add(tc); - } - }); - if (!exact.isEmpty()) - { - return Collections.unmodifiableList(exact); - } - if (!wrongcase.isEmpty()) - { - return Collections.unmodifiableList(wrongcase); - } - if (!startswith.isEmpty()) - { - return Collections.unmodifiableList(startswith); - } - return Collections.unmodifiableList(contains); - } - - /** - * Queries a provided instance of {@link net.dv8tion.jda.api.JDA JDA} for {@link net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel - * VoiceChannel}s. - *

- * If a {@link net.dv8tion.jda.api.sharding.ShardManager ShardManager} is available this will query across that - * instead of the JDA instance. - *

- * The standard search does not follow any special cases. - * - * @param query - * The String query to search by - * @param jda - * The instance of JDA to search from - * - * @return A possibly-empty {@link java.util.List List} of VoiceChannels found by the query from the provided JDA - * instance. - */ - public static List findVoiceChannels(String query, JDA jda) - { - return jdaVoiceChannelSearch(query, jda, true); - } - - /** - * Queries a provided instance of {@link net.dv8tion.jda.api.JDA JDA} for {@link net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel - * VoiceChannel}s. - *

- * This only queries the instance of JDA, regardless of whether or not a - * {@link net.dv8tion.jda.api.sharding.ShardManager ShardManager} is available. - *

- * The standard search does not follow any special cases. - * - * @param query - * The String query to search by - * @param jda - * The instance of JDA to search from - * - * @return A possibly-empty {@link java.util.List List} of VoiceChannels found by the query from the provided JDA - * instance. - */ - public static List findShardVoiceChannels(String query, JDA jda) - { - return jdaVoiceChannelSearch(query, jda, false); - } - - /** - * Queries a provided {@link net.dv8tion.jda.api.entities.Guild Guild} for {@link net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel VoiceChannel}s. - *

- * The standard search does not follow any special cases. - * - * @param query - * The String query to search by - * @param guild - * The Guild to search from - * - * @return A possibly-empty {@link java.util.List List} of VoiceChannels found by the query from the provided Guild. - */ - public static List findVoiceChannels(String query, Guild guild) - { - if (DISCORD_ID.matcher(query).matches()) - { - VoiceChannel vc = guild.getVoiceChannelById(query); - if (vc != null) - { - return Collections.singletonList(vc); - } - } - return genericVoiceChannelSearch(query, guild.getVoiceChannelCache()); - } - - private static List jdaVoiceChannelSearch(String query, JDA jda, boolean useShardManager) - { - ShardManager manager = useShardManager ? jda.getShardManager() : null; - if (DISCORD_ID.matcher(query).matches()) - { - VoiceChannel vc = manager != null ? manager.getVoiceChannelById(query) : jda.getVoiceChannelById(query); - if (vc != null) - { - return Collections.singletonList(vc); - } - } - return genericVoiceChannelSearch(query, manager != null ? manager.getVoiceChannelCache() : jda.getVoiceChannelCache()); - } - - private static List genericVoiceChannelSearch(String query, SnowflakeCacheView cache) - { - ArrayList exact = new ArrayList<>(); - ArrayList wrongcase = new ArrayList<>(); - ArrayList startswith = new ArrayList<>(); - ArrayList contains = new ArrayList<>(); - String lowerquery = query.toLowerCase(Locale.ROOT); - cache.forEach((vc) -> - { - String name = vc.getName(); - if (name.equals(query)) - { - exact.add(vc); - } else if (name.equalsIgnoreCase(query) && exact.isEmpty()) - { - wrongcase.add(vc); - } else if (name.toLowerCase(Locale.ROOT).startsWith(lowerquery) && wrongcase.isEmpty()) - { - startswith.add(vc); - } else if (name.toLowerCase(Locale.ROOT).contains(lowerquery) && startswith.isEmpty()) - { - contains.add(vc); - } - }); - if (!exact.isEmpty()) - { - return Collections.unmodifiableList(exact); - } - if (!wrongcase.isEmpty()) - { - return Collections.unmodifiableList(wrongcase); - } - if (!startswith.isEmpty()) - { - return Collections.unmodifiableList(startswith); - } - return Collections.unmodifiableList(contains); - } - - /** - * Queries a provided instance of {@link net.dv8tion.jda.api.JDA JDA} for {@link net.dv8tion.jda.api.entities.channel.concrete.Category - * Categories}. - *

- * If a {@link net.dv8tion.jda.api.sharding.ShardManager ShardManager} is available this will query across that - * instead of the JDA instance. - *

- * The standard search does not follow any special cases. - * - * @param query - * The String query to search by - * @param jda - * The instance of JDA to search from - * - * @return A possibly-empty {@link java.util.List List} of Categories found by the query from the provided JDA - * instance. - */ - public static List findCategories(String query, JDA jda) - { - return jdaCategorySearch(query, jda, true); - } - - /** - * Queries a provided instance of {@link net.dv8tion.jda.api.JDA JDA} for {@link net.dv8tion.jda.api.entities.channel.concrete.Category - * Categories}. - *

- * This only queries the instance of JDA, regardless of whether or not a - * {@link net.dv8tion.jda.api.sharding.ShardManager ShardManager} is available. - *

- * The standard search does not follow any special cases. - * - * @param query - * The String query to search by - * @param jda - * The instance of JDA to search from - * - * @return A possibly-empty {@link java.util.List List} of Categories found by the query from the provided JDA - * instance. - */ - public static List findShardCategories(String query, JDA jda) - { - return jdaCategorySearch(query, jda, false); - } - - /** - * Queries a provided {@link net.dv8tion.jda.api.entities.Guild Guild} for {@link net.dv8tion.jda.api.entities.channel.concrete.Category Categories}. - *

- * The standard search does not follow any special cases. - * - * @param query - * The String query to search by - * @param guild - * The Guild to search from - * - * @return A possibly-empty {@link java.util.List List} of Categories found by the query from the provided Guild. - */ - public static List findCategories(String query, Guild guild) - { - if (DISCORD_ID.matcher(query).matches()) - { - Category cat = guild.getCategoryById(query); - if (cat != null) - { - return Collections.singletonList(cat); - } - } - return genericCategorySearch(query, guild.getCategoryCache()); - } - - private static List jdaCategorySearch(String query, JDA jda, boolean useShardManager) - { - ShardManager manager = useShardManager ? jda.getShardManager() : null; - if (DISCORD_ID.matcher(query).matches()) - { - Category cat = manager != null ? manager.getCategoryById(query) : jda.getCategoryById(query); - if (cat != null) - { - return Collections.singletonList(cat); - } - } - return genericCategorySearch(query, jda.getCategoryCache()); - } - - private static List genericCategorySearch(String query, SnowflakeCacheView cache) - { - ArrayList exact = new ArrayList<>(); - ArrayList wrongcase = new ArrayList<>(); - ArrayList startswith = new ArrayList<>(); - ArrayList contains = new ArrayList<>(); - String lowerquery = query.toLowerCase(Locale.ROOT); - cache.forEach(cat -> - { - String name = cat.getName(); - if (name.equals(query)) - { - exact.add(cat); - } else if (name.equalsIgnoreCase(query) && exact.isEmpty()) - { - wrongcase.add(cat); - } else if (name.toLowerCase(Locale.ROOT).startsWith(lowerquery) && wrongcase.isEmpty()) - { - startswith.add(cat); - } else if (name.toLowerCase(Locale.ROOT).contains(lowerquery) && startswith.isEmpty()) - { - contains.add(cat); - } - }); - if (!exact.isEmpty()) - { - return Collections.unmodifiableList(exact); - } - if (!wrongcase.isEmpty()) - { - return Collections.unmodifiableList(wrongcase); - } - if (!startswith.isEmpty()) - { - return Collections.unmodifiableList(startswith); - } - return Collections.unmodifiableList(contains); - } - - /** - * Queries a provided {@link net.dv8tion.jda.api.entities.Guild Guild} for {@link net.dv8tion.jda.api.entities.Role Role}s. - *

- * The following special case is applied before the standard search is done: - *

    - *
  • Role Mention: Query provided matches a @role mention (more specifically {@literal <@&roleID>})
  • - *
- * - * @param query - * The String query to search by - * @param guild - * The Guild to search from - * - * @return A possibly-empty {@link java.util.List List} of Roles found by the query from the provided Guild. - */ - public static List findRoles(String query, Guild guild) - { - Matcher roleMention = ROLE_MENTION.matcher(query); - if (roleMention.matches()) - { - Role role = guild.getRoleById(roleMention.group(1)); - if (role != null) - { - return Collections.singletonList(role); - } - } else if (DISCORD_ID.matcher(query).matches()) - { - Role role = guild.getRoleById(query); - if (role != null) - { - return Collections.singletonList(role); - } - } - ArrayList exact = new ArrayList<>(); - ArrayList wrongcase = new ArrayList<>(); - ArrayList startswith = new ArrayList<>(); - ArrayList contains = new ArrayList<>(); - String lowerquery = query.toLowerCase(Locale.ROOT); - guild.getRoleCache().forEach((role) -> - { - String name = role.getName(); - if (name.equals(query)) - { - exact.add(role); - } else if (name.equalsIgnoreCase(query) && exact.isEmpty()) - { - wrongcase.add(role); - } else if (name.toLowerCase(Locale.ROOT).startsWith(lowerquery) && wrongcase.isEmpty()) - { - startswith.add(role); - } else if (name.toLowerCase(Locale.ROOT).contains(lowerquery) && startswith.isEmpty()) - { - contains.add(role); - } - }); - if (!exact.isEmpty()) - { - return Collections.unmodifiableList(exact); - } - if (!wrongcase.isEmpty()) - { - return Collections.unmodifiableList(wrongcase); - } - if (!startswith.isEmpty()) - { - return Collections.unmodifiableList(startswith); - } - return Collections.unmodifiableList(contains); - } - - /** - * Queries a provided instance of {@link net.dv8tion.jda.api.JDA JDA} for {@link net.dv8tion.jda.api.entities.emoji.Emoji Emoji}s. - *

- * If a {@link net.dv8tion.jda.api.sharding.ShardManager ShardManager} is available this will query across that - * instead of the JDA instance. - *

- * The following special case is applied before the standard search is done: - *

    - *
  • Emoji Mention: Query provided matches a :Emoji: mention (more specifically {@literal <:EmojiName:EmojiID>}). - *
    - * Note: This only returns here if the Emoji is valid. Validity being the ID retrieves a non-null Emoji and - * that the {@link net.dv8tion.jda.api.entities.emoji.Emoji#getName() name} of the Emoji is equal to the name found in the query.
  • - *
- * - * @param query - * The String query to search by - * @param jda - * The instance of JDA to search from - * - * @return A possibly-empty {@link java.util.List List} of Emojis found by the query from the provided JDA instance. - */ - public static List findEmojis(String query, JDA jda) - { - return jdaFindEmojis(query, jda, true); - } - - /** - * Queries a provided instance of {@link net.dv8tion.jda.api.JDA JDA} for {@link net.dv8tion.jda.api.entities.emoji.Emoji Emoji}s. - *

- * This only queries the instance of JDA, regardless of whether or not a - * {@link net.dv8tion.jda.api.sharding.ShardManager ShardManager} is available. - *

- * The following special case is applied before the standard search is done: - *

    - *
  • Emoji Mention: Query provided matches a :Emoji: mention (more specifically {@literal <:EmojiName:EmojiID>}). - *
    - * Note: This only returns here if the Emoji is valid. Validity being the ID retrieves a non-null Emoji and - * that the {@link net.dv8tion.jda.api.entities.emoji.Emoji#getName() name} of the Emoji is equal to the name found in the query.
  • - *
- * - * @param query - * The String query to search by - * @param jda - * The instance of JDA to search from - * - * @return A possibly-empty {@link java.util.List List} of Emojis found by the query from the provided JDA instance. - */ - public static List findShardEmojis(String query, JDA jda) - { - return jdaFindEmojis(query, jda, false); - } - - /** - * Queries a provided {@link net.dv8tion.jda.api.entities.Guild Guild} for {@link net.dv8tion.jda.api.entities.emoji.Emoji Emoji}s. - *

- * The following special case is applied before the standard search is done: - *

    - *
  • Emoji Mention: Query provided matches a :Emoji: mention (more specifically {@literal <:EmojiName:EmojiID>}). - *
    - * Note: This only returns here if the Emoji is valid. Validity being the ID retrieves a non-null Emoji and - * that the {@link net.dv8tion.jda.api.entities.emoji.Emoji#getName() name} of the Emoji is equal to the name found in the query.
  • - *
- * - * @param query - * The String query to search by - * @param guild - * The Guild to search from - * - * @return A possibly-empty {@link java.util.List List} of Emojis found by the query from the provided Guild. - */ - public static List findEmojis(String query, Guild guild) - { - Matcher mentionMatcher = Emoji_MENTION.matcher(query); - if (DISCORD_ID.matcher(query).matches()) - { - Emoji Emoji = guild.getEmojiById(query); - if (Emoji != null) - { - return Collections.singletonList(Emoji); - } - } else if (mentionMatcher.matches()) - { - String EmojiName = mentionMatcher.group(1); - String EmojiId = mentionMatcher.group(2); - Emoji Emoji = guild.getEmojiById(EmojiId); - if ((Emoji != null) && Emoji.getName().equals(EmojiName)) - { - return Collections.singletonList(Emoji); - } - } - return genericEmojiSearch(query, guild.getEmojiCache()); - } - - private static List jdaFindEmojis(String query, JDA jda, boolean useShardManager) - { - Matcher mentionMatcher = Emoji_MENTION.matcher(query); - - ShardManager manager = useShardManager ? jda.getShardManager() : null; - if (DISCORD_ID.matcher(query).matches()) - { - Emoji Emoji = manager != null ? manager.getEmojiById(query) : jda.getEmojiById(query); - if (Emoji != null) - { - return Collections.singletonList(Emoji); - } - } else if (mentionMatcher.matches()) - { - String EmojiName = mentionMatcher.group(1); - String EmojiId = mentionMatcher.group(2); - Emoji Emoji = manager != null ? manager.getEmojiById(EmojiId) : jda.getEmojiById(EmojiId); - if ((Emoji != null) && Emoji.getName().equals(EmojiName)) - { - return Collections.singletonList(Emoji); - } - } - return genericEmojiSearch(query, jda.getEmojiCache()); - } - - private static List genericEmojiSearch(String query, SnowflakeCacheView cache) - { - ArrayList exact = new ArrayList<>(); - ArrayList wrongcase = new ArrayList<>(); - ArrayList startswith = new ArrayList<>(); - ArrayList contains = new ArrayList<>(); - String lowerquery = query.toLowerCase(Locale.ROOT); - cache.forEach(Emoji -> - { - String name = Emoji.getName(); - if (name.equals(query)) - { - exact.add(Emoji); - } else if (name.equalsIgnoreCase(query) && exact.isEmpty()) - { - wrongcase.add(Emoji); - } else if (name.toLowerCase(Locale.ROOT).startsWith(lowerquery) && wrongcase.isEmpty()) - { - startswith.add(Emoji); - } else if (name.toLowerCase(Locale.ROOT).contains(lowerquery) && startswith.isEmpty()) - { - contains.add(Emoji); - } - }); - if (!exact.isEmpty()) - { - return Collections.unmodifiableList(exact); - } - if (!wrongcase.isEmpty()) - { - return Collections.unmodifiableList(wrongcase); - } - if (!startswith.isEmpty()) - { - return Collections.unmodifiableList(startswith); - } - return Collections.unmodifiableList(contains); - } - - // Prevent instantiation - private FinderUtil() - { - } -} diff --git a/src/main/java/io/github/readonly/common/util/Functional.java b/src/main/java/io/github/readonly/common/util/Functional.java index 1a5ad12..20dd2c1 100644 --- a/src/main/java/io/github/readonly/common/util/Functional.java +++ b/src/main/java/io/github/readonly/common/util/Functional.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util; import java.util.Arrays; diff --git a/src/main/java/io/github/readonly/common/util/KeyValueSupplier.java b/src/main/java/io/github/readonly/common/util/KeyValueSupplier.java index ff1c5b0..5d24e8a 100644 --- a/src/main/java/io/github/readonly/common/util/KeyValueSupplier.java +++ b/src/main/java/io/github/readonly/common/util/KeyValueSupplier.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util; public interface KeyValueSupplier diff --git a/src/main/java/io/github/readonly/common/util/ProfilingUtil.java b/src/main/java/io/github/readonly/common/util/ProfilingUtil.java index da97377..e85a6fd 100644 --- a/src/main/java/io/github/readonly/common/util/ProfilingUtil.java +++ b/src/main/java/io/github/readonly/common/util/ProfilingUtil.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util; import java.util.List; diff --git a/src/main/java/io/github/readonly/common/util/RGB.java b/src/main/java/io/github/readonly/common/util/RGB.java index 10cacd9..b54b3bb 100644 --- a/src/main/java/io/github/readonly/common/util/RGB.java +++ b/src/main/java/io/github/readonly/common/util/RGB.java @@ -1,20 +1,25 @@ /* - * Library License + * This file is part of JDATools, licensed under the MIT License (MIT). * - * Copyright (c) 2021 ReadOnly Development + * Copyright (c) ROMVoid95 * - * This 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 io.github.readonly.common.util; diff --git a/src/main/java/io/github/readonly/common/util/SafeIdUtil.java b/src/main/java/io/github/readonly/common/util/SafeIdUtil.java index 1db108c..5d7a0a2 100644 --- a/src/main/java/io/github/readonly/common/util/SafeIdUtil.java +++ b/src/main/java/io/github/readonly/common/util/SafeIdUtil.java @@ -27,71 +27,9 @@ import lombok.experimental.UtilityClass; import net.dv8tion.jda.api.utils.MiscUtil; -/** - * A Utilities class for safely checking and converting String IDs to longs usable with - * {@link MiscUtil#parseSnowflake(String) MiscUtil.parseSnowflake(String)}, a utility used in several - * {@code Object#getXById(String)} methods. - *

- * This class contains two static methods: - *

    - *
  • {@link SafeIdUtil#safeConvert(String) SafeIdUtil.safeConvert(String)} - Safely converts a String to a format - * usable with {@code MiscUtil.parseSnowflake(String)}.
  • - *
  • {@link SafeIdUtil#checkId(String) SafeIdUtil.checkId(String)} - Checks if a String is safe to use with - * {@code MiscUtil.parseSnowflake(String)} as it is.
  • - *
- * - * @since 1.2 - */ @UtilityClass public class SafeIdUtil { - /** - * Safely convert the provided String ID to a {@code long} usable with {@link MiscUtil#parseSnowflake(String) - * MiscUtil.parseSnowflake(String)}. - * - * @param id - * The String ID to be converted - * - * @return If the String can be converted into a non-negative {@code long}, then it will return the conversion.
- * However, if one of the following criteria is met, then this method will return {@code 0L}: - *
    - *
  • If the provided String throws a {@link java.lang.NumberFormatException NumberFormatException} when - * used with {@link java.lang.Long#parseLong(String) Long.parseLong(String)}.
  • - *
  • If the provided String is converted, but the returned {@code long} is negative.
  • - *
- */ - public static long safeConvert(String id) - { - try - { - long l = Long.parseLong(id.trim()); - if (l < 0) - { - return 0L; - } - return l; - } catch (NumberFormatException e) - { - return 0L; - } - } - - public static String safeConvert(long id) - { - try - { - String s = Long.toString(id); - if (FinderUtil.DISCORD_ID.matcher(s).matches()) - { - return s; - } - return ""; - } catch (Exception e) - { - return ""; - } - } - /** * Checks if the provided String ID is usable with {@link MiscUtil#parseSnowflake(String) * MiscUtil.parseSnowflake(String)}. diff --git a/src/main/java/io/github/readonly/common/util/WebLink.java b/src/main/java/io/github/readonly/common/util/WebLink.java index a1e7f69..f9df88d 100644 --- a/src/main/java/io/github/readonly/common/util/WebLink.java +++ b/src/main/java/io/github/readonly/common/util/WebLink.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util; import okhttp3.HttpUrl; diff --git a/src/main/java/io/github/readonly/common/util/async/Async.java b/src/main/java/io/github/readonly/common/util/async/Async.java index bcfe743..fff24e8 100644 --- a/src/main/java/io/github/readonly/common/util/async/Async.java +++ b/src/main/java/io/github/readonly/common/util/async/Async.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util.async; import java.util.Objects; diff --git a/src/main/java/io/github/readonly/common/util/async/RateLimiter.java b/src/main/java/io/github/readonly/common/util/async/RateLimiter.java index b2bc228..d287947 100644 --- a/src/main/java/io/github/readonly/common/util/async/RateLimiter.java +++ b/src/main/java/io/github/readonly/common/util/async/RateLimiter.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util.async; import java.util.HashMap; diff --git a/src/main/java/io/github/readonly/common/util/async/threads/CompletableThread.java b/src/main/java/io/github/readonly/common/util/async/threads/CompletableThread.java index b1b727e..e28bef9 100644 --- a/src/main/java/io/github/readonly/common/util/async/threads/CompletableThread.java +++ b/src/main/java/io/github/readonly/common/util/async/threads/CompletableThread.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util.async.threads; import java.util.concurrent.Callable; diff --git a/src/main/java/io/github/readonly/common/util/async/threads/DeathTimer.java b/src/main/java/io/github/readonly/common/util/async/threads/DeathTimer.java index 9811ebc..82aadcb 100644 --- a/src/main/java/io/github/readonly/common/util/async/threads/DeathTimer.java +++ b/src/main/java/io/github/readonly/common/util/async/threads/DeathTimer.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util.async.threads; import java.util.Objects; diff --git a/src/main/java/io/github/readonly/common/util/async/threads/ScheduledTaskProcessor.java b/src/main/java/io/github/readonly/common/util/async/threads/ScheduledTaskProcessor.java index 0cf5527..3bfaf0e 100644 --- a/src/main/java/io/github/readonly/common/util/async/threads/ScheduledTaskProcessor.java +++ b/src/main/java/io/github/readonly/common/util/async/threads/ScheduledTaskProcessor.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util.async.threads; import java.util.ArrayList; diff --git a/src/main/java/io/github/readonly/common/util/async/threads/builder/ThreadBuilder.java b/src/main/java/io/github/readonly/common/util/async/threads/builder/ThreadBuilder.java index f71a2e4..7a266e0 100644 --- a/src/main/java/io/github/readonly/common/util/async/threads/builder/ThreadBuilder.java +++ b/src/main/java/io/github/readonly/common/util/async/threads/builder/ThreadBuilder.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util.async.threads.builder; import java.util.concurrent.ThreadFactory; diff --git a/src/main/java/io/github/readonly/common/util/holding/HoldingUtils.java b/src/main/java/io/github/readonly/common/util/holding/HoldingUtils.java index fd12f9a..8a919f7 100644 --- a/src/main/java/io/github/readonly/common/util/holding/HoldingUtils.java +++ b/src/main/java/io/github/readonly/common/util/holding/HoldingUtils.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util.holding; import java.util.Iterator; diff --git a/src/main/java/io/github/readonly/common/util/holding/objects/Holder.java b/src/main/java/io/github/readonly/common/util/holding/objects/Holder.java index 50299ed..a746f5b 100644 --- a/src/main/java/io/github/readonly/common/util/holding/objects/Holder.java +++ b/src/main/java/io/github/readonly/common/util/holding/objects/Holder.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util.holding.objects; import java.util.Objects; diff --git a/src/main/java/io/github/readonly/common/util/holding/objects/Indexed.java b/src/main/java/io/github/readonly/common/util/holding/objects/Indexed.java index 3b8f622..b58548a 100644 --- a/src/main/java/io/github/readonly/common/util/holding/objects/Indexed.java +++ b/src/main/java/io/github/readonly/common/util/holding/objects/Indexed.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util.holding.objects; import java.util.concurrent.atomic.AtomicInteger; diff --git a/src/main/java/io/github/readonly/common/util/holding/objects/Pointer.java b/src/main/java/io/github/readonly/common/util/holding/objects/Pointer.java index 9f590ec..35fae52 100644 --- a/src/main/java/io/github/readonly/common/util/holding/objects/Pointer.java +++ b/src/main/java/io/github/readonly/common/util/holding/objects/Pointer.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util.holding.objects; import java.lang.ref.WeakReference; diff --git a/src/main/java/io/github/readonly/common/util/holding/objects/Switch.java b/src/main/java/io/github/readonly/common/util/holding/objects/Switch.java index d6c1824..b288d4a 100644 --- a/src/main/java/io/github/readonly/common/util/holding/objects/Switch.java +++ b/src/main/java/io/github/readonly/common/util/holding/objects/Switch.java @@ -1,3 +1,27 @@ +/* + * This file is part of JDATools, licensed under the MIT License (MIT). + * + * Copyright (c) ROMVoid95 + * + * 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 io.github.readonly.common.util.holding.objects; import java.util.function.BooleanSupplier; diff --git a/src/main/java/io/github/readonly/doc/annotation/docstandard/Error.java b/src/main/java/io/github/readonly/doc/annotation/docstandard/Error.java index 2b42a98..5e8b2ea 100644 --- a/src/main/java/io/github/readonly/doc/annotation/docstandard/Error.java +++ b/src/main/java/io/github/readonly/doc/annotation/docstandard/Error.java @@ -24,7 +24,13 @@ package io.github.readonly.doc.annotation.docstandard; -import java.lang.annotation.*; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import io.github.readonly.doc.ConvertedBy; import io.github.readonly.doc.DocMultiple; @@ -46,7 +52,7 @@ * multiples of these can be attached to a class or method. *

* Below is a visual of what this should generally look like: - * + * *

  *     Possible Errors:
  *     • "I encountered an issue while processing this command!" - Houston had a problem!
@@ -62,7 +68,7 @@
 @Repeatable(Errors.class)
 @Retention(RetentionPolicy.RUNTIME)
 @Target(
-{ ElementType.TYPE, ElementType.METHOD })
+	{ ElementType.TYPE, ElementType.METHOD })
 public @interface Error
 {
 	/**
@@ -107,7 +113,9 @@ public String read(Error annotation)
 		{
 			StringBuilder b = new StringBuilder(annotation.prefix());
 			if (!annotation.response().isEmpty())
+			{
 				b.append("\"").append(annotation.response()).append("\" - ");
+			}
 			b.append(annotation.value());
 			return b.toString();
 		}
diff --git a/src/main/java/io/github/readonly/rmi/RMIConnectorServer.java b/src/main/java/io/github/readonly/rmi/RMIConnectorServer.java
index d5684e4..90f64c5 100644
--- a/src/main/java/io/github/readonly/rmi/RMIConnectorServer.java
+++ b/src/main/java/io/github/readonly/rmi/RMIConnectorServer.java
@@ -1,3 +1,27 @@
+/*
+ * This file is part of JDATools, licensed under the MIT License (MIT).
+ *
+ * Copyright (c) ROMVoid95
+ *
+ * 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 io.github.readonly.rmi;
 
 import java.lang.management.ManagementFactory;
diff --git a/src/main/java/io/github/readonly/scheduler/AbstractScheduler.java b/src/main/java/io/github/readonly/scheduler/AbstractScheduler.java
index 02672ff..b7c3440 100644
--- a/src/main/java/io/github/readonly/scheduler/AbstractScheduler.java
+++ b/src/main/java/io/github/readonly/scheduler/AbstractScheduler.java
@@ -1,8 +1,7 @@
 /*
- * This file is part of Sponge, licensed under the MIT License (MIT).
+ * This file is part of JDATools, licensed under the MIT License (MIT).
  *
- * Copyright (c) SpongePowered 
- * Copyright (c) contributors
+ * Copyright (c) ROMVoid95
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -22,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+
 package io.github.readonly.scheduler;
 
 import java.util.Map;
diff --git a/src/main/java/io/github/readonly/scheduler/AsyncScheduler.java b/src/main/java/io/github/readonly/scheduler/AsyncScheduler.java
index bafb55e..d799479 100644
--- a/src/main/java/io/github/readonly/scheduler/AsyncScheduler.java
+++ b/src/main/java/io/github/readonly/scheduler/AsyncScheduler.java
@@ -1,8 +1,7 @@
 /*
- * This file is part of Sponge, licensed under the MIT License (MIT).
+ * This file is part of JDATools, licensed under the MIT License (MIT).
  *
- * Copyright (c) SpongePowered 
- * Copyright (c) contributors
+ * Copyright (c) ROMVoid95
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -22,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+
 package io.github.readonly.scheduler;
 
 import java.util.Set;
diff --git a/src/main/java/io/github/readonly/scheduler/BotScheduler.java b/src/main/java/io/github/readonly/scheduler/BotScheduler.java
index e9da449..cc04332 100644
--- a/src/main/java/io/github/readonly/scheduler/BotScheduler.java
+++ b/src/main/java/io/github/readonly/scheduler/BotScheduler.java
@@ -1,8 +1,7 @@
 /*
- * This file is part of Sponge, licensed under the MIT License (MIT).
+ * This file is part of JDATools, licensed under the MIT License (MIT).
  *
- * Copyright (c) SpongePowered 
- * Copyright (c) contributors
+ * Copyright (c) ROMVoid95
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -22,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+
 package io.github.readonly.scheduler;
 
 import static com.google.common.base.Preconditions.checkArgument;
diff --git a/src/main/java/io/github/readonly/scheduler/BotTaskBuilder.java b/src/main/java/io/github/readonly/scheduler/BotTaskBuilder.java
index bf7f9d9..922d778 100644
--- a/src/main/java/io/github/readonly/scheduler/BotTaskBuilder.java
+++ b/src/main/java/io/github/readonly/scheduler/BotTaskBuilder.java
@@ -1,8 +1,7 @@
 /*
- * This file is part of Sponge, licensed under the MIT License (MIT).
+ * This file is part of JDATools, licensed under the MIT License (MIT).
  *
- * Copyright (c) SpongePowered 
- * Copyright (c) contributors
+ * Copyright (c) ROMVoid95
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -22,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+
 package io.github.readonly.scheduler;
 
 import static com.google.common.base.Preconditions.checkArgument;
diff --git a/src/main/java/io/github/readonly/scheduler/ScheduledTask.java b/src/main/java/io/github/readonly/scheduler/ScheduledTask.java
index 24622b3..590f265 100644
--- a/src/main/java/io/github/readonly/scheduler/ScheduledTask.java
+++ b/src/main/java/io/github/readonly/scheduler/ScheduledTask.java
@@ -1,8 +1,7 @@
 /*
- * This file is part of Sponge, licensed under the MIT License (MIT).
+ * This file is part of JDATools, licensed under the MIT License (MIT).
  *
- * Copyright (c) SpongePowered 
- * Copyright (c) contributors
+ * Copyright (c) ROMVoid95
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -22,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+
 package io.github.readonly.scheduler;
 
 import java.util.UUID;
diff --git a/src/main/java/io/github/readonly/scheduler/SyncScheduler.java b/src/main/java/io/github/readonly/scheduler/SyncScheduler.java
index b5def24..9c648f5 100644
--- a/src/main/java/io/github/readonly/scheduler/SyncScheduler.java
+++ b/src/main/java/io/github/readonly/scheduler/SyncScheduler.java
@@ -1,8 +1,7 @@
 /*
- * This file is part of Sponge, licensed under the MIT License (MIT).
+ * This file is part of JDATools, licensed under the MIT License (MIT).
  *
- * Copyright (c) SpongePowered 
- * Copyright (c) contributors
+ * Copyright (c) ROMVoid95
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -22,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+
 package io.github.readonly.scheduler;
 
 public class SyncScheduler extends AbstractScheduler {
diff --git a/src/main/java/io/github/readonly/scheduler/Task.java b/src/main/java/io/github/readonly/scheduler/Task.java
index 669921c..a9e51a1 100644
--- a/src/main/java/io/github/readonly/scheduler/Task.java
+++ b/src/main/java/io/github/readonly/scheduler/Task.java
@@ -1,3 +1,27 @@
+/*
+ * This file is part of JDATools, licensed under the MIT License (MIT).
+ *
+ * Copyright (c) ROMVoid95
+ *
+ * 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 io.github.readonly.scheduler;
 
 import io.github.readonly.api.scheduler.ITask;
diff --git a/src/main/java/io/github/readonly/scheduler/TaskExecutorService.java b/src/main/java/io/github/readonly/scheduler/TaskExecutorService.java
index 01b240a..60923c5 100644
--- a/src/main/java/io/github/readonly/scheduler/TaskExecutorService.java
+++ b/src/main/java/io/github/readonly/scheduler/TaskExecutorService.java
@@ -1,8 +1,7 @@
 /*
- * This file is part of Sponge, licensed under the MIT License (MIT).
+ * This file is part of JDATools, licensed under the MIT License (MIT).
  *
- * Copyright (c) SpongePowered 
- * Copyright (c) contributors
+ * Copyright (c) ROMVoid95
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -22,6 +21,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+
 package io.github.readonly.scheduler;
 
 import java.util.List;