Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
xGab0 committed Jun 23, 2024
2 parents 29a894f + 970407a commit 3ba5000
Show file tree
Hide file tree
Showing 21 changed files with 712 additions and 62 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: 'adopt'

- name: Grant execute permission for gradlew
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![banner](.github/logo.gif)

# Minestom Launcher
![Java 17](https://img.shields.io/badge/language-Java%2017-9B599A.svg?label=language&style=for-the-badge&logo=github&logoColor=ff6c32&labelColor=ffffff&color=ff76b6)
![Java 21](https://img.shields.io/badge/language-Java%2017-9B599A.svg?label=language&style=for-the-badge&logo=github&logoColor=ff6c32&labelColor=ffffff&color=ff76b6)
[![GitHub license](https://img.shields.io/github/license/The-Crown-Studios/MinestomLauncher?label=license&style=for-the-badge&logo=gitbook&logoColor=ff6c32&labelColor=ffffff&color=ff76b6)](https://github.com/The-Crown-Studios/MinestomLauncher/blob/main/LICENSE)

Minestom Launcher is a Java software that runs a [Minestom](https://minestom.net/) server like you would do with Bukkit/Sponge/Quilt.
Expand Down
101 changes: 65 additions & 36 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

group = "com.thecrownstudios"
version = "1.2.4"

plugins {
id("java")
id("com.github.johnrengelman.shadow") version "8.1.1"
}

base {
group = "com.thecrownstudios"
version = "1.2.4"
archivesName = "minestom-launcher"
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

toolchain {
languageVersion = JavaLanguageVersion.of(21)
}

tasks.withType<ProcessResources> {
filteringCharset = "UTF-8"
Expand All @@ -33,28 +38,10 @@ java {
}
}

shadow {
tasks.withType<ShadowJar> {
exclude("server.json")

println(message = "SHADOWJAR INFORMATION")
println(message = "- project_name: ${rootProject.name}")
println(message = "- module_name: ${archiveBaseName.get()}")
println(message = "- module_version: ${archiveVersion.get()}")
println(message = "- module_extension: ${archiveExtension.get()}")
println()

archiveFileName.set("${rootProject.name}-${archiveVersion.get()}.${archiveExtension.get()}")
}
}

repositories {
mavenCentral()

maven {
name = "JitPack"
url = uri("https://jitpack.io")
}
maven { url = uri("https://jitpack.io") }
maven {
name = "Sponge"
url = uri("https://repo.spongepowered.org/maven")
Expand All @@ -63,26 +50,68 @@ repositories {
name = "Sonatype"
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
maven {
name = "CentralSonatype"
url = uri("https://central.sonatype.com/")
}
maven {
name = "Minecraft"
url = uri("https://libraries.minecraft.net")
}
}

dependencies {
val minestom_version = project.property("minestom_version")!! as String
val jnoise_version = project.property("jnoise_version")!! as String
val minimessage_version = project.property("minimessage_version")!! as String
val jackson_version = project.property("jackson_version")!! as String

implementation("com.github.Minestom:Minestom:$minestom_version")
implementation("de.articdive:jnoise-pipeline:$jnoise_version")
implementation("com.github.CatDevz:SlimeLoader:master-SNAPSHOT")
implementation("net.kyori:adventure-text-minimessage:$minimessage_version")
implementation("com.fasterxml.jackson.core:jackson-databind:$jackson_version")
val minestom_version = findProperty("minestom_version")
val minestom_extensions_version = findProperty("minestom_extensions_version")

val slimeloader_version = findProperty("slimeloader_version")
val polar_version = findProperty("polar_version")

val minimessage_version = findProperty("minimessage_version")
val jackson_version = findProperty("jackson_version")
val jnoise_version = findProperty("jnoise_version")

val ansi_version = findProperty("ansi_version")
val jansi_version = findProperty("jansi_version")
val jline_version = findProperty("jline_version")
val jline_terminal_jansi_version = findProperty("jline_terminal_jansi_version")
val log4j_version = findProperty("log4j_version")

// Minestom modules
implementation("net.minestom", "minestom-snapshots", "$minestom_version")
implementation("dev.hollowcube", "minestom-ce-extensions", "$minestom_extensions_version")

// World formats
implementation("com.github.CatDevz", "SlimeLoader", "$slimeloader_version")
implementation("dev.hollowcube", "polar", "$polar_version")

// Misc
implementation("net.kyori", "adventure-text-minimessage", "$minimessage_version")
implementation("com.fasterxml.jackson.core", "jackson-databind", "$jackson_version")
implementation("de.articdive", "jnoise-pipeline", "$jnoise_version")

// Terminal & Logging
implementation("net.kyori", "ansi", "$ansi_version")
implementation("org.fusesource.jansi", "jansi", "$jansi_version")
implementation("org.jline", "jline", "$jline_version")
implementation("org.jline", "jline-terminal-jansi", "$jline_terminal_jansi_version")
implementation("org.apache.logging.log4j", "log4j-core", "$log4j_version")
}

tasks {
shadowJar {
exclude("server.json")

println(message = "ShadowJar Informations")
println(message = "- project_name: ${rootProject.name}")
println(message = "- module_name: ${archiveBaseName.get()}")
println(message = "- module_version: ${archiveVersion.get()}")
println(message = "- module_extension: ${archiveExtension.get()}")
println()

archiveFileName.set("${rootProject.name}-${archiveVersion.get()}.${archiveExtension.get()}")
}

build {
finalizedBy(shadowJar)
}
Expand Down
14 changes: 11 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ version = 1.2.4
description = A launcher made for Minestom

# libraries versions
minestom_version = 2cdb3911b0
jnoise_version = 4.1.0-SNAPSHOT
minestom_version = f1d5940855
minestom_extensions_version = 1.2.0
polar_version = 1.9.5
slimeloader_version = master-SNAPSHOT
minimessage_version = 4.14.0
jackson_version = 2.15.2
jackson_version = 2.15.2
jnoise_version = 4.1.0-SNAPSHOT
ansi_version = 1.0.3
jansi_version = 2.4.1
jline_version = 3.26.2
jline_terminal_jansi_version = 3.26.2
log4j_version = 2.23.1
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,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
import com.thecrownstudios.minestomlauncher.util.FileUtil;
import com.thecrownstudios.minestomlauncher.util.InstanceGenUtil;
import com.thecrownstudios.minestomlauncher.util.ObjectTriple;
import net.hollowcube.minestom.extensions.ExtensionBootstrap;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.CommandManager;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.entity.Player;
import net.minestom.server.event.player.PlayerLoginEvent;
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
import net.minestom.server.extras.MojangAuth;
import net.minestom.server.extras.bungee.BungeeCordProxy;
import net.minestom.server.extras.lan.OpenToLAN;
import net.minestom.server.extras.optifine.OptifineSupport;
import net.minestom.server.extras.velocity.VelocityProxy;
import net.minestom.server.instance.InstanceContainer;
import net.minestom.server.instance.InstanceManager;
Expand Down Expand Up @@ -63,15 +63,20 @@ private void start(long startMillis, @NotNull FileResult result, @NotNull Minest
System.setProperty("minestom.chunk-view-distance", String.valueOf(serverData.chunkViewDistance()));
System.setProperty("minestom.entity-view-distance", String.valueOf(serverData.entityViewDistance()));

MinecraftServer minecraftServer = MinecraftServer.init();
// Without Extensions
// MinecraftServer minecraftServer = MinecraftServer.init();

// With Extensions
ExtensionBootstrap minecraftServer = ExtensionBootstrap.init();

if (networkData.openToLan()) {
OpenToLAN.open();
}

if (serverData.optifineSupport()) {
OptifineSupport.enable();
}
// Optifine is dead, going to remove it
//if (serverData.optifineSupport()) {
// OptifineSupport.enable();
//}

if (proxyData.enabled()) {
String proxyType = proxyData.type();
Expand All @@ -97,7 +102,7 @@ private void start(long startMillis, @NotNull FileResult result, @NotNull Minest
InstanceGenUtil.loadInstance(instanceTypeName, instanceContainer);
instanceManager.registerInstance(instanceContainer);

MinecraftServer.getGlobalEventHandler().addListener(PlayerLoginEvent.class, event -> {
MinecraftServer.getGlobalEventHandler().addListener(AsyncPlayerConfigurationEvent.class, event -> {
Player player = event.getPlayer();

event.setSpawningInstance(instanceContainer);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.thecrownstudios.minestomlauncher.console;

import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.apache.logging.log4j.core.appender.rewrite.RewritePolicy;
import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.core.layout.PatternLayout;
import org.jetbrains.annotations.Nullable;
import org.jline.reader.LineReader;

final class ConsoleAppender extends AbstractAppender {
private final LineReader lineReader;
private final @Nullable RewritePolicy rewriter;

ConsoleAppender(
final LineReader lineReader,
final String logPattern,
final @Nullable RewritePolicy rewritePolicy
) {
super(
"Console",
null,
PatternLayout.newBuilder().withPattern(logPattern).build(),
false,
new Property[0]
);
this.lineReader = lineReader;
this.rewriter = rewritePolicy;
}

private LogEvent rewrite(final LogEvent event) {
return this.rewriter == null ? event : this.rewriter.rewrite(event);
}

@Override
public void append(final LogEvent event) {
if (this.lineReader.isReading()) {
this.lineReader.callWidget(LineReader.CLEAR);
}

this.lineReader.getTerminal().writer().print(this.getLayout().toSerializable(this.rewrite(event)).toString());

if (this.lineReader.isReading()) {
this.lineReader.callWidget(LineReader.REDRAW_LINE);
this.lineReader.callWidget(LineReader.REDISPLAY);
}
this.lineReader.getTerminal().writer().flush();
}
}
Loading

0 comments on commit 3ba5000

Please sign in to comment.