Skip to content

Commit

Permalink
feat: upgrade Minecraft (1.19 -> 1.19.2) (#69)
Browse files Browse the repository at this point in the history
deps: upgrade all dependencies

build: only depend on the required `fabric-api` modules
  • Loading branch information
axieum authored Oct 13, 2022
1 parent 87f71dd commit c351b26
Show file tree
Hide file tree
Showing 29 changed files with 113 additions and 100 deletions.
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ plugins {
id 'java'
id 'checkstyle'
id 'maven-publish'
id 'com.modrinth.minotaur' version '2.2.1'
id 'com.modrinth.minotaur' version '2.3.1'
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '1.0-SNAPSHOT'
}

allprojects {
Expand All @@ -30,7 +30,6 @@ allprojects {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Mods
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Code Quality
compileOnly "org.jetbrains:annotations:${project.jetbrains_annotations_version}"
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ mod_version = 1.1.0-beta.3
## {x-release-please-end}

# Fabric
minecraft_version = 1.19
loader_version = 0.14.8
yarn_mappings = 1.19+build.4
fabric_version = 0.58.0+1.19
minecraft_version = 1.19.2
loader_version = 0.14.9
yarn_mappings = 1.19.2+build.20
fabric_version = 0.62.0+1.19.2

# Dependencies
checkstyle_version = 10.3
checkstyle_version = 10.3.4
jetbrains_annotations_version = 23.0.0
junit_jupiter_version = 5.8.2
junit_jupiter_version = 5.9.1

# CurseForge
cf_project_id = 502254
cf_game_versions = Fabric, Java 17, 1.19
cf_game_versions = Fabric, Java 17, 1.19.1, 1.19.2
cf_relations_required = fabric-api
cf_relations_optional =
cf_relations_embedded = cloth-config
Expand All @@ -28,7 +28,7 @@ cf_relations_incompatible =

# Modrinth
mr_project_id = DoVQa3oa
mr_game_versions = 1.19
mr_game_versions = 1.19.1, 1.19.2
mr_relations_required = P7dR8mSH
mr_relations_optional =
mr_relations_incompatible =
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,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.
Expand Down
14 changes: 8 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +40,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.
Expand Down Expand Up @@ -75,13 +75,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
Expand Down
4 changes: 3 additions & 1 deletion minecord-api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Declare dependencies
dependencies {
api include(fabricApi.module("fabric-api-base", project.fabric_version))
modApi include(fabricApi.module("fabric-lifecycle-events-v1", project.fabric_version))
modApi include("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude module: 'modmenu'
}
implementation shade("com.vdurmont:emoji-java:${project.emoji_java_version}")
implementation shade("net.dv8tion:JDA:${project.jda_version}") {
exclude module: 'opus-java' // exclude audio
}
implementation shade("org.apache.logging.log4j:log4j-slf4j18-impl:${project.log4j_version}") {
implementation shade("org.apache.logging.log4j:log4j-slf4j2-impl:${project.log4j_version}") {
exclude module: 'log4j-api' // exclude log4j itself, we transitively use via Minecraft
exclude module: 'log4j-core'
}
Expand Down
6 changes: 3 additions & 3 deletions minecord-api/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod_version = 1.1.0-beta.3
## {x-release-please-end}

# Dependencies
cloth_config_version = 7.0.65
cloth_config_version = 8.2.88
emoji_java_version = 5.1.1
jda_version = 5.0.0-alpha.12
log4j_version = 2.17.2
jda_version = 5.0.0-alpha.21
log4j_version = 2.19.0
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface MinecordAddon
*
* <p>NB: This is called before building the JDA client! To use the built
* client once connected, you can attach an event listener and observe the
* {@link net.dv8tion.jda.api.events.ReadyEvent} for the client.
* {@link net.dv8tion.jda.api.events.session.ReadyEvent} for the client.
*
* @param builder JDA client builder
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import java.util.Optional;

import javax.security.auth.login.LoginException;

import me.shedaniel.autoconfig.ConfigHolder;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.exceptions.InvalidTokenException;
import net.dv8tion.jda.api.requests.GatewayIntent;
import net.dv8tion.jda.api.utils.ChunkingFilter;
import net.dv8tion.jda.api.utils.MemberCachePolicy;
Expand Down Expand Up @@ -55,6 +54,8 @@ public void onPreLaunch()
try {
// Prepare the JDA client
final JDABuilder builder = JDABuilder.createDefault(getConfig().bot.token)
// allow the bot to read message contents
.enableIntents(GatewayIntent.MESSAGE_CONTENT)
// set initial bot status
.setStatus(getConfig().bot.status.starting)
// add event listeners
Expand All @@ -74,7 +75,7 @@ public void onPreLaunch()
JDAEvents.BUILD_CLIENT.invoker().onBuildClient(builder);
LOGGER.info("Logging into Discord...");
client = builder.build();
} catch (LoginException | IllegalArgumentException e) {
} catch (InvalidTokenException | IllegalArgumentException e) {
LOGGER.error("Unable to login to Discord: {}", e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.axieum.mcmod.minecord.impl.callback;

import net.dv8tion.jda.api.events.ReadyEvent;
import net.dv8tion.jda.api.events.ShutdownEvent;
import net.dv8tion.jda.api.events.session.ReadyEvent;
import net.dv8tion.jda.api.events.session.ShutdownEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.jetbrains.annotations.NotNull;

Expand Down
4 changes: 2 additions & 2 deletions minecord-api/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
],
"depends": {
"java": ">=17",
"minecraft": "1.19.x",
"minecraft": "~1.19.1",
"fabricloader": ">=0.11.3",
"fabric": "*"
"fabric-lifecycle-events-v1": "*"
}
}
3 changes: 3 additions & 0 deletions minecord-chat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ dependencies {
implementation project(path: ':minecord-api', configuration: 'namedElements')
implementation project(path: ':minecord-api', configuration: 'shadow')
implementation shade("io.github.java-diff-utils:java-diff-utils:${project.java_diff_utils_version}")
modApi include(fabricApi.module("fabric-entity-events-v1", project.fabric_version))
modApi include(fabricApi.module("fabric-message-api-v1", project.fabric_version))
modApi include(fabricApi.module("fabric-networking-api-v1", project.fabric_version))
}
2 changes: 1 addition & 1 deletion minecord-chat/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ mod_version = 1.1.0-beta.3
## {x-release-please-end}

# Dependencies
java_diff_utils_version = 4.11
java_diff_utils_version = 4.12
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
import net.minecraft.network.message.SignedMessage;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.filter.FilteredMessage;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.util.crash.CrashReport;
import net.minecraft.util.registry.RegistryKey;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
Expand Down Expand Up @@ -283,19 +281,19 @@ public static final class Minecraft
* Called when a player sent an in-game message via the {@code /me} command.
*/
public static final Event<EmoteCommand> EMOTE_COMMAND =
EventFactory.createArrayBacked(EmoteCommand.class, callbacks -> (st, source, action) -> {
EventFactory.createArrayBacked(EmoteCommand.class, callbacks -> (st, source, action, params) -> {
for (EmoteCommand callback : callbacks) {
callback.onEmoteCommandPlaceholder(st, source, action);
callback.onEmoteCommandPlaceholder(st, source, action, params);
}
});

/**
* Called when an admin broadcast an in-game message via the {@code /say} command.
*/
public static final Event<SayCommand> SAY_COMMAND =
EventFactory.createArrayBacked(SayCommand.class, callbacks -> (st, source, action) -> {
EventFactory.createArrayBacked(SayCommand.class, callbacks -> (st, source, action, params) -> {
for (SayCommand callback : callbacks) {
callback.onSayCommandPlaceholder(st, source, action);
callback.onSayCommandPlaceholder(st, source, action, params);
}
});

Expand Down Expand Up @@ -414,14 +412,11 @@ public interface PlayerChat
* @param template mutable string template
* @param player author of the message
* @param message received message contents
* @param typeKey received message type
* @param params received message parameters
* @see net.fabricmc.fabric.api.message.v1.ServerMessageEvents#CHAT_MESSAGE
*/
void onPlayerChatPlaceholder(
StringTemplate template,
ServerPlayerEntity player,
FilteredMessage<SignedMessage> message,
RegistryKey<MessageType> typeKey
StringTemplate template, ServerPlayerEntity player, SignedMessage message, MessageType.Parameters params
);
}

Expand Down Expand Up @@ -487,13 +482,12 @@ public interface EmoteCommand
* @param template mutable string template
* @param source source of the command, e.g. a player
* @param action received message contents
* @param params received message parameters
* @see net.minecraft.network.message.MessageType#EMOTE_COMMAND
* @see net.fabricmc.fabric.api.message.v1.ServerMessageEvents#COMMAND_MESSAGE
*/
void onEmoteCommandPlaceholder(
StringTemplate template,
ServerCommandSource source,
FilteredMessage<SignedMessage> action
StringTemplate template, ServerCommandSource source, SignedMessage action, MessageType.Parameters params
);
}

Expand All @@ -511,13 +505,12 @@ public interface SayCommand
* @param template mutable string template
* @param source source of the message, e.g. a player
* @param action received message contents
* @param params received message parameters
* @see net.minecraft.network.message.MessageType#SAY_COMMAND
* @see net.fabricmc.fabric.api.message.v1.ServerMessageEvents#COMMAND_MESSAGE
*/
void onSayCommandPlaceholder(
StringTemplate template,
ServerCommandSource source,
FilteredMessage<SignedMessage> action
StringTemplate template, ServerCommandSource source, SignedMessage action, MessageType.Parameters params
);
}

Expand All @@ -535,7 +528,6 @@ public interface TellRawCommand
* @param template mutable string template
* @param source source of the message, e.g. a player
* @param message received message contents
* @see net.minecraft.network.message.MessageType#TELLRAW_COMMAND
*/
void onTellRawCommandPlaceholder(StringTemplate template, ServerCommandSource source, Text message);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.axieum.mcmod.minecord.impl.chat.callback.discord;

import net.dv8tion.jda.api.entities.MessageReaction;
import net.dv8tion.jda.api.events.message.react.GenericMessageReactionEvent;
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
Expand Down Expand Up @@ -30,8 +29,7 @@ public void onGenericMessageReaction(GenericMessageReactionEvent event)
event.retrieveMessage().queue(context -> {
// Compute some useful properties of the event
final boolean isAdded = event instanceof MessageReactionAddEvent;
final MessageReaction.ReactionEmote reaction = event.getReactionEmote();
final String emote = reaction.isEmote() ? ":" + reaction.getName() + ":" : reaction.getName();
final String emote = ":" + event.getEmoji().getName() + ":";

/*
* Prepare a message template.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.time.Duration;
import java.util.Optional;

import net.dv8tion.jda.api.utils.FileUpload;
import org.jetbrains.annotations.Nullable;

import net.minecraft.server.MinecraftServer;
Expand Down Expand Up @@ -138,7 +139,7 @@ public void onServerShutdown(MinecraftServer server, @Nullable CrashReport crash
(action, entry) -> {
// Conditionally attach the crash report if required
if (entry.discord.uploadCrashReport)
file.ifPresent(action::addFile);
file.map(FileUpload::fromData).ifPresent(action::addFiles);
action.queue();
},
entry -> entry.discord.crashed != null);
Expand Down
Loading

0 comments on commit c351b26

Please sign in to comment.