Skip to content

Commit 306d052

Browse files
committed
Update dependencies & use Optionals
Gradle Galaxy: 1.1.3 -> 1.2.3 Shadow: 8.1.7 -> 8.3.0 Java Utilities: 12eda02e55 -> a073202b43 Logback Classic: 1.5.3 -> 1.5.6
1 parent db06d41 commit 306d052

File tree

7 files changed

+30
-25
lines changed

7 files changed

+30
-25
lines changed

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import xyz.srnyx.gradlegalaxy.utility.setupPublishing
99

1010
plugins {
1111
application
12-
id("xyz.srnyx.gradle-galaxy") version "1.1.3"
13-
id("io.github.goooler.shadow") version "8.1.7"
12+
id("xyz.srnyx.gradle-galaxy") version "1.2.3"
13+
id("com.gradleup.shadow") version "8.3.0"
1414
}
1515

1616
setupJava("xyz.srnyx", "3.1.0", "A simple library for JDA Discord bots", JavaVersion.VERSION_19)
@@ -20,12 +20,12 @@ addCompilerArgs("-parameters")
2020
repository(Repository.MAVEN_CENTRAL, Repository.JITPACK)
2121
dependencies {
2222
compileOnly("net.dv8tion", "JDA", "5.0.2") // JDA
23-
implementation("xyz.srnyx", "java-utilities", "12eda02e55") // General Java utility library
23+
implementation("xyz.srnyx", "java-utilities", "a073202b43") // General Java utility library
2424
implementation("io.github.freya022", "BotCommands", "2.10.3") // Command framework
2525
implementation("org.spongepowered", "configurate-yaml", "4.1.2") // Config manager
2626
implementation("org.postgresql", "postgresql", "42.7.3") // Database
2727
implementation("com.zaxxer", "HikariCP", "5.1.0") // Database
28-
implementation("ch.qos.logback", "logback-classic", "1.5.3") // Logging
28+
implementation("ch.qos.logback", "logback-classic", "1.5.6") // Logging
2929
}
3030

3131
setupPublishing(

gradle/wrapper/gradle-wrapper.jar

130 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,8 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90+
' "$PWD" ) || exit
8891

8992
# Use the maximum available, or set MAX_FD != -1 to use that value.
9093
MAX_FD=maximum

gradlew.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################

src/main/java/xyz/srnyx/lazylibrary/utility/LazyMapper.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import xyz.srnyx.javautilities.MiscUtility;
1010

11+
import java.util.Optional;
12+
1113

1214
/**
1315
* A utility class for converting {@link Object Objects} to other types
@@ -18,10 +20,10 @@ public class LazyMapper {
1820
*
1921
* @param object the {@link String} to parse
2022
*
21-
* @return the {@link Long snowflake} or {@code null}
23+
* @return the {@link Long snowflake} or empty
2224
*/
23-
@Nullable
24-
public static Long parseSnowflake(@NotNull Object object) {
25+
@NotNull
26+
public static Optional<Long> parseSnowflake(@NotNull Object object) {
2527
return MiscUtility.handleException(() -> MiscUtil.parseSnowflake(object.toString()));
2628
}
2729

@@ -30,14 +32,11 @@ public static Long parseSnowflake(@NotNull Object object) {
3032
*
3133
* @param object the {@link Object} to convert
3234
*
33-
* @return the {@link UserSnowflake} or {@code null}
35+
* @return the {@link UserSnowflake} or empty
3436
*/
35-
@Nullable
36-
public static UserSnowflake toUserSnowflake(@Nullable Object object) {
37-
if (object == null) return null;
38-
final Long snowflake = parseSnowflake(object);
39-
if (snowflake == null) return null;
40-
return MiscUtility.handleException(() -> UserSnowflake.fromId(snowflake));
37+
@NotNull
38+
public static Optional<UserSnowflake> toUserSnowflake(@Nullable Object object) {
39+
return object == null ? Optional.empty() : parseSnowflake(object).flatMap(snowflake -> MiscUtility.handleException(() -> UserSnowflake.fromId(snowflake)));
4140
}
4241

4342
private LazyMapper() {

src/main/java/xyz/srnyx/lazylibrary/utility/LazyUtilities.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import org.jetbrains.annotations.NotNull;
2121

22-
import xyz.srnyx.javautilities.MiscUtility;
2322
import xyz.srnyx.javautilities.manipulation.Mapper;
2423

2524
import xyz.srnyx.lazylibrary.LazyEmoji;
@@ -56,21 +55,23 @@ public static PaginatorBuilder getDefaultPaginator() {
5655
*/
5756
public static boolean userHasChannelPermission(@NotNull Interaction interaction, @NotNull Permission... permissions) {
5857
final Member member = interaction.getMember();
59-
final GuildChannel channel = MiscUtility.handleException(() -> (GuildChannel) interaction.getChannel());
60-
if (member == null || channel == null) return false;
61-
return member.hasPermission(channel, permissions);
58+
return member != null && Mapper.to(interaction.getChannel(), GuildChannel.class)
59+
.map(channel -> member.hasPermission(channel, permissions))
60+
.orElse(false);
6261
}
6362

6463
@NotNull private static final Function<BoundExtractedResult<Command.Choice>, Command.Choice> STRING_MAPPING = BoundExtractedResult::getReferent;
6564
@NotNull private static final Function<BoundExtractedResult<Command.Choice>, Command.Choice> INTEGER_MAPPING = result -> {
6665
final Command.Choice choice = result.getReferent();
67-
final Long value = Mapper.toLong(choice.getAsString());
68-
return value == null ? null : new Command.Choice(choice.getName(), value);
66+
return Mapper.toLong(choice.getAsString())
67+
.map(value -> new Command.Choice(choice.getName(), value))
68+
.orElse(null);
6969
};
7070
@NotNull private static final Function<BoundExtractedResult<Command.Choice>, Command.Choice> NUMBER_MAPPING = result -> {
7171
final Command.Choice choice = result.getReferent();
72-
final Double value = Mapper.toDouble(choice.getAsString());
73-
return value == null ? null : new Command.Choice(choice.getName(), value);
72+
return Mapper.toDouble(choice.getAsString())
73+
.map(value -> new Command.Choice(choice.getName(), value))
74+
.orElse(null);
7475
};
7576

7677
/**

0 commit comments

Comments
 (0)