Skip to content

Commit

Permalink
Merge branch '1.18' into 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianVennen committed Jun 15, 2023
2 parents 8f6aca7 + b20e134 commit 4186ce5
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 47 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: |
17
8
11
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: init submodule
run: git submodule init && git submodule update
- name: Build with Gradle
run: ./gradlew build -Dorg.gradle.java.home="$JAVA_HOME_17_X64"
run: ./gradlew build --no-daemon -Dorg.gradle.java.home="$JAVA_HOME_17_X64"
15 changes: 7 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: |
8
17
11
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: init submodule
run: git submodule init && git submodule update
- name: Build with Gradle
run: JAVA_HOME="$JAVA_HOME_8_X64" ./gradlew build -Dorg.gradle.java.home="$JAVA_HOME_17_X64" -Prelease=${{ github.ref_name }}
run: ./gradlew build --no-daemon -Dorg.gradle.java.home="$JAVA_HOME_17_X64" -Prelease=${{ github.ref_name }}
- name: Create Release
uses: softprops/action-gh-release@v1
with:
Expand All @@ -31,8 +30,8 @@ jobs:
- name: Publish to Modrinth
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: JAVA_HOME="$JAVA_HOME_8_X64" ./gradlew modrinth -Dorg.gradle.java.home="$JAVA_HOME_17_X64" -Prelease=${{ github.ref_name }}
run: ./gradlew modrinth --no-daemon -Dorg.gradle.java.home="$JAVA_HOME_17_X64" -Prelease=${{ github.ref_name }}
- name: Publish to CurseForge
env:
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
run: JAVA_HOME="$JAVA_HOME_8_X64" ./gradlew publishCurseforge -Dorg.gradle.java.home="$JAVA_HOME_17_X64" -Prelease=${{ github.ref_name }}
run: ./gradlew publishCurseforge --no-daemon -Dorg.gradle.java.home="$JAVA_HOME_17_X64" -Prelease=${{ github.ref_name }}
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Allow sharing of crash reports
- Makes use of API version 4.0.0, allowing for marginal performance increases as API calls are now Async
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2022 Aternos GmbH
Copyright (c) 2020-2023 Aternos GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
23 changes: 14 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
plugins {
id 'java'
id 'fabric-loom' version '1.0-SNAPSHOT'
id "com.modrinth.minotaur" version "2.+"
id "net.darkhax.curseforgegradle" version "1.0.11"
id 'fabric-loom' version '1.2.7'
id "com.modrinth.minotaur" version "2.8.1"
id "net.darkhax.curseforgegradle" version "1.1.15"
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16

archivesBaseName = project.archives_base_name
version = project.hasProperty('release') ? project.getProperty('release') : 'dev'
Expand All @@ -15,8 +15,8 @@ changelog = rootProject.file("CHANGELOG.md").text

dependencies {
// Mclogs Java - Library to read, list and share logs to mclogs
implementation project(path: ":mclogs-java", configuration: 'default')
include project(path: ":mclogs-java", configuration: 'default')
implementation 'gs.mclo:api:4.0.1'
include 'gs.mclo:api:4.0.1'

//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
Expand All @@ -28,7 +28,7 @@ dependencies {
}

processResources {
def tag_version = project.version.split('-')[0];
def tag_version = project.version.split('-')[0]
inputs.property "version", tag_version

filesMatching("fabric.mod.json") {
Expand All @@ -41,6 +41,7 @@ processResources {
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
it.options.release = 16
}

jar {
Expand All @@ -56,6 +57,7 @@ modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = "6DdCzpTL"
uploadFile = "./build/libs/mclogs-fabric-${project.version}.jar"
loaders = ["fabric", "quilt"]
gameVersions = [
"1.19.3",
"1.19.2",
Expand All @@ -65,6 +67,7 @@ modrinth {
changelog = rootProject.changelog
dependencies {
required.project "fabric-api"
required.project "qsl"
}
}

Expand All @@ -74,7 +77,9 @@ task publishCurseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge)
mainFile.releaseType = 'release'
mainFile.changelogType = 'markdown'
mainFile.changelog = rootProject.changelog
mainFile.addRequirement('fabric-api')
mainFile.addModLoader("Quilt")
mainFile.addRequirement("fabric-api")
mainFile.addRequirement("qsl")
mainFile.addJavaVersion("Java ${JavaVersion.current().majorVersion}")
mainFile.addGameVersion("1.19.3")
mainFile.addGameVersion("1.19.2")
Expand Down
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.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 0 additions & 1 deletion mclogs-java
Submodule mclogs-java deleted from 9a37c2
4 changes: 0 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@ pluginManagement {
gradlePluginPortal()
}
}

rootProject.name = 'mclogs-fabric'
include ':mclogs-java'
project(':mclogs-java').projectDir = new File('./mclogs-java/')
32 changes: 18 additions & 14 deletions src/main/java/gs/mclo/fabric/MclogsFabricLoader.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package gs.mclo.fabric;

import com.mojang.brigadier.context.CommandContext;
import gs.mclo.java.APIResponse;
import gs.mclo.java.Log;
import gs.mclo.java.MclogsAPI;
import gs.mclo.api.Log;
import gs.mclo.api.MclogsClient;
import gs.mclo.api.response.UploadLogResponse;
import net.fabricmc.api.DedicatedServerModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.loader.api.FabricLoader;
Expand All @@ -19,17 +19,20 @@
import java.io.IOException;
import java.nio.file.Path;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class MclogsFabricLoader implements DedicatedServerModInitializer {
public static final Logger logger = LogManager.getLogger();
private static final MclogsClient client = new MclogsClient("Mclogs-fabric");

/**
* @param context command context
* @return log files
* @throws IOException io exception
*/
public static String[] getLogs(CommandContext<ServerCommandSource> context) throws IOException {
return MclogsAPI.listLogs(context.getSource().getServer().getRunDirectory().getCanonicalPath());
return client.listLogsInDirectory(context.getSource().getServer().getRunDirectory().getCanonicalPath());
}

/**
Expand All @@ -38,11 +41,11 @@ public static String[] getLogs(CommandContext<ServerCommandSource> context) thro
* @throws IOException io exception
*/
public static String[] getCrashReports(CommandContext<ServerCommandSource> context) throws IOException {
return MclogsAPI.listCrashReports(context.getSource().getServer().getRunDirectory().getCanonicalPath());
return client.listCrashReportsInDirectory(context.getSource().getServer().getRunDirectory().getCanonicalPath());
}

public static int share(ServerCommandSource source, String filename) {
MclogsAPI.mcversion = source.getServer().getVersion();
client.setMinecraftVersion(source.getServer().getVersion());
logger.log(Level.INFO,"Sharing "+filename);
source.sendFeedback(Text.literal("Sharing " + filename), false);

Expand Down Expand Up @@ -71,22 +74,24 @@ public static int share(ServerCommandSource source, String filename) {
}

try {
APIResponse response = MclogsAPI.share(log);
if (response.success) {
CompletableFuture<UploadLogResponse> response = client.uploadLog(log);
UploadLogResponse res = response.get();
res.setClient(client);
if (res.isSuccess()) {
MutableText feedback = Text.literal("Your log has been uploaded: ");
feedback.setStyle(Style.EMPTY.withColor(Formatting.GREEN));

MutableText link = Text.literal(response.url);
MutableText link = Text.literal(res.getUrl());
Style linkStyle = Style.EMPTY.withColor(Formatting.BLUE);
linkStyle = linkStyle.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,response.url));
linkStyle = linkStyle.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,res.getUrl()));
link.setStyle(linkStyle);

source.sendFeedback(feedback.append(link),true);
return 1;
}
else {
logger.error("An error occurred when uploading your log: ");
logger.error(response.error);
logger.error(res.getError());
source.sendError(Text.literal("An error occurred. Check your log for more details"));
return 0;
}
Expand All @@ -95,7 +100,7 @@ public static int share(ServerCommandSource source, String filename) {
source.sendError(Text.literal("The log file "+filename+" doesn't exist. Use '/mclogs list' to list all logs."));
return -1;
}
catch (IOException e) {
catch (IOException | InterruptedException | ExecutionException e) {
source.sendError(Text.literal("An error occurred. Check your log for more details"));
logger.error("Could not get log file!");
logger.error(e);
Expand All @@ -105,10 +110,9 @@ public static int share(ServerCommandSource source, String filename) {

@Override
public void onInitializeServer() {
MclogsAPI.userAgent = "Mclogs-fabric";
Optional<ModContainer> mclogs = FabricLoader.getInstance().getModContainer("mclogs");
MclogsAPI.version = mclogs.isPresent() ? mclogs.get().getMetadata().getVersion().getFriendlyString() : "unknown";

client.setProjectVersion(mclogs.isPresent() ? mclogs.get().getMetadata().getVersion().getFriendlyString() : "unknown");
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, dedicated) -> {
CommandMclogs.register(dispatcher);
CommandMclogsList.register(dispatcher);
Expand Down

0 comments on commit 4186ce5

Please sign in to comment.