Skip to content

Commit 4eeb4c1

Browse files
authored
feat: cave block palette, scale animator, deps updates
Add cave block palette and scale animators
2 parents be47d5c + 34c615b commit 4eeb4c1

14 files changed

+184
-151
lines changed

Dockerfile

-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ FROM --platform=$TARGETPLATFORM azul/zulu-openjdk:21-jre
33
RUN mkdir /app
44
WORKDIR /app
55

6-
# Download packages
7-
RUN apt-get update && apt-get install -y wget
8-
96
COPY build/libs/*-all.jar /app/marathon.jar
107

118
ENTRYPOINT ["java"]

build.gradle.kts

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
plugins {
22
java
3-
id("com.gradleup.shadow") version "8.3.0"
3+
application
4+
id("com.gradleup.shadow") version "8.3.3"
45
}
56

67
group = "dev.emortal.minestom"
78
version = "1.0-SNAPSHOT"
9+
application.mainClass = "dev.emortal.minestom.marathon.Main"
810

911
repositories {
1012
mavenCentral()
@@ -20,8 +22,8 @@ dependencies {
2022
implementation("dev.emortal.minestom:game-sdk:4f505ad") {
2123
exclude(group = "dev.emortal.api", module = "common-proto-sdk")
2224
}
23-
implementation("dev.emortal.api:common-proto-sdk:2584fd2")
2425

26+
implementation("dev.emortal.api:common-proto-sdk:2584fd2")
2527
implementation("net.kyori:adventure-text-minimessage:4.17.0")
2628
}
2729

@@ -37,12 +39,15 @@ tasks {
3739

3840
manifest {
3941
attributes(
40-
"Main-Class" to "dev.emortal.minestom.marathon.Main",
4142
"Multi-Release" to true
4243
)
4344
}
4445
}
4546

47+
withType<JavaCompile> {
48+
options.encoding = "UTF-8"
49+
}
50+
4651
withType<AbstractArchiveTask> {
4752
isPreserveFileTimestamps = false
4853
isReproducibleFileOrder = true

gradle/wrapper/gradle-wrapper.properties

+1-1
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.10-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew.bat

+94-94
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,94 @@
1-
@rem
2-
@rem Copyright 2015 the original author or authors.
3-
@rem
4-
@rem Licensed under the Apache License, Version 2.0 (the "License");
5-
@rem you may not use this file except in compliance with the License.
6-
@rem You may obtain a copy of the License at
7-
@rem
8-
@rem https://www.apache.org/licenses/LICENSE-2.0
9-
@rem
10-
@rem Unless required by applicable law or agreed to in writing, software
11-
@rem distributed under the License is distributed on an "AS IS" BASIS,
12-
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
@rem See the License for the specific language governing permissions and
14-
@rem limitations under the License.
15-
@rem
16-
@rem SPDX-License-Identifier: Apache-2.0
17-
@rem
18-
19-
@if "%DEBUG%"=="" @echo off
20-
@rem ##########################################################################
21-
@rem
22-
@rem Gradle startup script for Windows
23-
@rem
24-
@rem ##########################################################################
25-
26-
@rem Set local scope for the variables with windows NT shell
27-
if "%OS%"=="Windows_NT" setlocal
28-
29-
set DIRNAME=%~dp0
30-
if "%DIRNAME%"=="" set DIRNAME=.
31-
@rem This is normally unused
32-
set APP_BASE_NAME=%~n0
33-
set APP_HOME=%DIRNAME%
34-
35-
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
36-
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37-
38-
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39-
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40-
41-
@rem Find java.exe
42-
if defined JAVA_HOME goto findJavaFromJavaHome
43-
44-
set JAVA_EXE=java.exe
45-
%JAVA_EXE% -version >NUL 2>&1
46-
if %ERRORLEVEL% equ 0 goto execute
47-
48-
echo. 1>&2
49-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50-
echo. 1>&2
51-
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52-
echo location of your Java installation. 1>&2
53-
54-
goto fail
55-
56-
:findJavaFromJavaHome
57-
set JAVA_HOME=%JAVA_HOME:"=%
58-
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59-
60-
if exist "%JAVA_EXE%" goto execute
61-
62-
echo. 1>&2
63-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64-
echo. 1>&2
65-
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66-
echo location of your Java installation. 1>&2
67-
68-
goto fail
69-
70-
:execute
71-
@rem Setup the command line
72-
73-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74-
75-
76-
@rem Execute Gradle
77-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78-
79-
:end
80-
@rem End local scope for the variables with windows NT shell
81-
if %ERRORLEVEL% equ 0 goto mainEnd
82-
83-
:fail
84-
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85-
rem the _cmd.exe /c_ return code!
86-
set EXIT_CODE=%ERRORLEVEL%
87-
if %EXIT_CODE% equ 0 set EXIT_CODE=1
88-
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89-
exit /b %EXIT_CODE%
90-
91-
:mainEnd
92-
if "%OS%"=="Windows_NT" endlocal
93-
94-
:omega
1+
@rem
2+
@rem Copyright 2015 the original author or authors.
3+
@rem
4+
@rem Licensed under the Apache License, Version 2.0 (the "License");
5+
@rem you may not use this file except in compliance with the License.
6+
@rem You may obtain a copy of the License at
7+
@rem
8+
@rem https://www.apache.org/licenses/LICENSE-2.0
9+
@rem
10+
@rem Unless required by applicable law or agreed to in writing, software
11+
@rem distributed under the License is distributed on an "AS IS" BASIS,
12+
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
@rem See the License for the specific language governing permissions and
14+
@rem limitations under the License.
15+
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
18+
19+
@if "%DEBUG%"=="" @echo off
20+
@rem ##########################################################################
21+
@rem
22+
@rem Gradle startup script for Windows
23+
@rem
24+
@rem ##########################################################################
25+
26+
@rem Set local scope for the variables with windows NT shell
27+
if "%OS%"=="Windows_NT" setlocal
28+
29+
set DIRNAME=%~dp0
30+
if "%DIRNAME%"=="" set DIRNAME=.
31+
@rem This is normally unused
32+
set APP_BASE_NAME=%~n0
33+
set APP_HOME=%DIRNAME%
34+
35+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
36+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37+
38+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40+
41+
@rem Find java.exe
42+
if defined JAVA_HOME goto findJavaFromJavaHome
43+
44+
set JAVA_EXE=java.exe
45+
%JAVA_EXE% -version >NUL 2>&1
46+
if %ERRORLEVEL% equ 0 goto execute
47+
48+
echo. 1>&2
49+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50+
echo. 1>&2
51+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52+
echo location of your Java installation. 1>&2
53+
54+
goto fail
55+
56+
:findJavaFromJavaHome
57+
set JAVA_HOME=%JAVA_HOME:"=%
58+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59+
60+
if exist "%JAVA_EXE%" goto execute
61+
62+
echo. 1>&2
63+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64+
echo. 1>&2
65+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66+
echo location of your Java installation. 1>&2
67+
68+
goto fail
69+
70+
:execute
71+
@rem Setup the command line
72+
73+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74+
75+
76+
@rem Execute Gradle
77+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78+
79+
:end
80+
@rem End local scope for the variables with windows NT shell
81+
if %ERRORLEVEL% equ 0 goto mainEnd
82+
83+
:fail
84+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85+
rem the _cmd.exe /c_ return code!
86+
set EXIT_CODE=%ERRORLEVEL%
87+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
88+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89+
exit /b %EXIT_CODE%
90+
91+
:mainEnd
92+
if "%OS%"=="Windows_NT" endlocal
93+
94+
:omega

src/main/java/dev/emortal/minestom/marathon/Main.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package dev.emortal.minestom.marathon;
22

33
import dev.emortal.api.model.gamedata.GameDataGameMode;
4-
import dev.emortal.api.model.gamedata.V1BlockSumoPlayerData;
54
import dev.emortal.api.model.gamedata.V1MarathonData;
65
import dev.emortal.api.utils.GrpcStubCollection;
76
import dev.emortal.minestom.core.module.messaging.MessagingModule;
@@ -40,6 +39,7 @@ public static void main(String[] args) {
4039
.minPlayers(1)
4140
.gameCreator(info -> {
4241
Map<UUID, V1MarathonData> playerData;
42+
4343
try {
4444
playerData = playerStorage.getPlayerData(info.playerIds());
4545
} catch (Exception e) {

src/main/java/dev/emortal/minestom/marathon/MarathonGame.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@
88
import dev.emortal.api.model.gamedata.GameDataGameMode;
99
import dev.emortal.api.model.gamedata.V1MarathonData;
1010
import dev.emortal.api.utils.kafka.FriendlyKafkaProducer;
11-
import dev.emortal.minestom.core.module.messaging.MessagingModule;
1211
import dev.emortal.minestom.marathon.animator.BlockAnimator;
13-
import dev.emortal.minestom.marathon.animator.PathAnimator;
1412
import dev.emortal.minestom.marathon.generator.DefaultGenerator;
1513
import dev.emortal.minestom.marathon.generator.Generator;
1614
import dev.emortal.minestom.marathon.options.BlockAnimation;
1715
import dev.emortal.minestom.marathon.options.BlockPalette;
1816
import dev.emortal.minestom.marathon.options.Time;
1917
import dev.emortal.minestom.marathon.util.BlockPacketUtils;
2018
import dev.emortal.minestom.marathon.util.EnumLore;
21-
import io.grpc.protobuf.ProtoUtils;
2219
import net.kyori.adventure.sound.Sound;
2320
import net.kyori.adventure.text.Component;
2421
import net.kyori.adventure.text.format.NamedTextColor;
@@ -56,7 +53,6 @@
5653
import java.util.Collection;
5754
import java.util.Date;
5855
import java.util.List;
59-
import java.util.Set;
6056
import java.util.concurrent.ThreadLocalRandom;
6157
import java.util.function.Supplier;
6258
import java.util.stream.Collectors;
@@ -76,7 +72,7 @@ public final class MarathonGame {
7672
.collect(Collectors.toUnmodifiableSet()));
7773

7874
private final @NotNull Instance instance;
79-
private final @NotNull FriendlyKafkaProducer producer;
75+
private final @Nullable FriendlyKafkaProducer producer;
8076
private final @NotNull Player player;
8177
private final @NotNull Generator generator;
8278

@@ -98,7 +94,7 @@ public final class MarathonGame {
9894

9995
private @Nullable Task breakingTask;
10096

101-
MarathonGame(@NotNull DynamicRegistry.Key<DimensionType> dimension, @NotNull FriendlyKafkaProducer producer,
97+
MarathonGame(@NotNull DynamicRegistry.Key<DimensionType> dimension, @Nullable FriendlyKafkaProducer producer,
10298
@NotNull Player player, V1MarathonData playerData) {
10399
this.time = Time.valueOf(playerData.getTime());
104100
this.palette = BlockPalette.valueOf(playerData.getBlockPalette());
@@ -159,6 +155,10 @@ void onJoin(@NotNull Player player) {
159155
}
160156

161157
private void produceDataUpdate() {
158+
if (this.producer == null) {
159+
return;
160+
}
161+
162162
this.producer.produceAndForget(UpdateGamePlayerDataMessage.newBuilder()
163163
.setGameMode(GameDataGameMode.MARATHON)
164164
.setPlayerId(this.player.getUuid().toString())
@@ -180,15 +180,15 @@ void cleanUp() {
180180
void refreshInventory() {
181181
ItemStack timeItem = ItemStack.of(Material.CLOCK)
182182
.with(ItemComponent.ITEM_NAME, Component.text("Time of Day", NamedTextColor.GREEN))
183-
.with(ItemComponent.LORE, EnumLore.createLore(this.time, Time.values(), Time::getFriendlyName));
183+
.with(ItemComponent.LORE, EnumLore.createLore(this.time, Time.values()));
184184

185185
ItemStack paletteItem = ItemStack.of(this.palette.getIcon())
186186
.with(ItemComponent.ITEM_NAME, Component.text("Block Palette", NamedTextColor.GREEN))
187-
.with(ItemComponent.LORE, EnumLore.createLore(this.palette, BlockPalette.values(), BlockPalette::getFriendlyName));
187+
.with(ItemComponent.LORE, EnumLore.createLore(this.palette, BlockPalette.values()));
188188

189189
ItemStack animatorItem = ItemStack.of(Material.COMPASS)
190190
.with(ItemComponent.ITEM_NAME, Component.text("Block Animation", NamedTextColor.GREEN))
191-
.with(ItemComponent.LORE, EnumLore.createLore(this.animation, BlockAnimation.values(), BlockAnimation::getFriendlyName));
191+
.with(ItemComponent.LORE, EnumLore.createLore(this.animation, BlockAnimation.values()));
192192

193193
this.player.getInventory().setItemStack(MarathonGame.TIME_SLOT, timeItem);
194194
this.player.getInventory().setItemStack(MarathonGame.PALETTE_SLOT, paletteItem);

src/main/java/dev/emortal/minestom/marathon/MarathonGameRunner.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,19 @@ public final class MarathonGameRunner extends Game {
2525
private final Map<UUID, MarathonGame> games = Collections.synchronizedMap(new HashMap<>());
2626
private final Map<UUID, V1MarathonData> playerData;
2727
private final DynamicRegistry.Key<DimensionType> dimension;
28-
private final FriendlyKafkaProducer kafkaProducer;
28+
private final @Nullable FriendlyKafkaProducer kafkaProducer;
2929

30-
public MarathonGameRunner(@NotNull GameCreationInfo creationInfo, @NotNull MessagingModule messaging,
30+
public MarathonGameRunner(@NotNull GameCreationInfo creationInfo, @Nullable MessagingModule messaging,
3131
@NotNull DynamicRegistry.Key<DimensionType> dimension, @NotNull Map<UUID, V1MarathonData> playerData) {
3232
super(creationInfo);
3333
this.playerData = playerData;
3434
this.dimension = dimension;
35-
this.kafkaProducer = messaging.getKafkaProducer();
35+
36+
if (messaging != null) {
37+
this.kafkaProducer = messaging.getKafkaProducer();
38+
} else {
39+
this.kafkaProducer = null;
40+
}
3641

3742
MovementListener movementListener = new MovementListener(this);
3843

@@ -48,8 +53,11 @@ public void start() {
4853

4954
@Override
5055
public void onJoin(@NotNull Player player) {
51-
V1MarathonData data = this.playerData.get(player.getUuid());
52-
MarathonGame game = this.games.computeIfAbsent(player.getUuid(), uuid -> new MarathonGame(this.dimension, this.kafkaProducer, player, data));
56+
V1MarathonData data = this.playerData.getOrDefault(player.getUuid(), Main.DEFAULT_PLAYER_DATA);
57+
58+
MarathonGame game = this.games.computeIfAbsent(player.getUuid(), uuid -> new MarathonGame(
59+
this.dimension, this.kafkaProducer, player, data));
60+
5361
game.onJoin(player);
5462
}
5563

src/main/java/dev/emortal/minestom/marathon/animator/RiseAnimator.java

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import dev.emortal.minestom.marathon.MarathonGame;
44
import dev.emortal.minestom.marathon.util.NoPhysicsEntity;
5-
import net.kyori.adventure.text.Component;
6-
import net.minestom.server.adventure.audience.Audiences;
75
import net.minestom.server.coordinate.Point;
86
import net.minestom.server.coordinate.Pos;
97
import net.minestom.server.coordinate.Vec;

src/main/java/dev/emortal/minestom/marathon/generator/DefaultGenerator.java

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package dev.emortal.minestom.marathon.generator;
22

33
import net.minestom.server.coordinate.Point;
4-
import net.minestom.server.utils.position.PositionUtils;
54
import org.jetbrains.annotations.NotNull;
65

76
import java.util.concurrent.ThreadLocalRandom;

0 commit comments

Comments
 (0)