chore: Updated dependencies

This commit is contained in:
2026-01-24 22:06:20 +01:00
parent 6e665dbbdd
commit 5193b4aba8
5 changed files with 71 additions and 58 deletions

44
pom.xml
View File

@@ -8,7 +8,6 @@
<artifactId>game</artifactId> <artifactId>game</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@@ -89,14 +88,9 @@
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.38</version> <version>1.18.42</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
</dependency>
<dependency> <dependency>
<groupId>org.reflections</groupId> <groupId>org.reflections</groupId>
@@ -107,25 +101,31 @@
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>31.1-jre</version> <version>33.5.0-jre</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>tools.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>2.18.2</version> <version>3.0.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId> <groupId>tools.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId> <artifactId>jackson-dataformat-yaml</artifactId>
<version>2.18.2</version> <version>3.0.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit</artifactId> <artifactId>junit-jupiter</artifactId>
<version>4.13.2</version> <version>6.0.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>6.0.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
@@ -134,21 +134,18 @@
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
<version>2.0.17</version> <version>2.0.17</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
<version>1.5.18</version> <version>1.5.25</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.trilarion</groupId> <groupId>com.github.trilarion</groupId>
<artifactId>java-vorbis-support</artifactId> <artifactId>java-vorbis-support</artifactId>
<version>1.2.1</version> <version>1.2.1</version>
</dependency> </dependency>
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>5.6.2</version>
</dependency>
<dependency> <dependency>
<groupId>com.googlecode.lanterna</groupId> <groupId>com.googlecode.lanterna</groupId>
@@ -159,13 +156,13 @@
<dependency> <dependency>
<groupId>org.bytedeco</groupId> <groupId>org.bytedeco</groupId>
<artifactId>javacv-platform</artifactId> <artifactId>javacv-platform</artifactId>
<version>1.5.10</version> <version>1.5.12</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bytedeco</groupId> <groupId>org.bytedeco</groupId>
<artifactId>ffmpeg-platform</artifactId> <artifactId>ffmpeg-platform</artifactId>
<version>6.1.1-1.5.10</version> <version>7.1.1-1.5.12</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -173,6 +170,7 @@
<artifactId>core</artifactId> <artifactId>core</artifactId>
<version>2.5</version> <version>2.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>be.tarsos.dsp</groupId> <groupId>be.tarsos.dsp</groupId>
<artifactId>jvm</artifactId> <artifactId>jvm</artifactId>

View File

@@ -8,6 +8,8 @@ import cz.jzitnik.utils.ScheduledTaskManager;
import cz.jzitnik.utils.ThreadManager; import cz.jzitnik.utils.ThreadManager;
import org.reflections.Reflections; import org.reflections.Reflections;
import java.io.IOException;
public class Game { public class Game {
private final DependencyManager dependencyManager = new DependencyManager(new Reflections("cz.jzitnik")); private final DependencyManager dependencyManager = new DependencyManager(new Reflections("cz.jzitnik"));
@@ -22,14 +24,10 @@ public class Game {
@InjectDependency @InjectDependency
private GlobalIOHandlerRepository globalIOHandlerRepository; private GlobalIOHandlerRepository globalIOHandlerRepository;
public void start() { public void start() throws IOException {
dependencyManager.inject(this); dependencyManager.inject(this);
try { gameSetup.setup();
gameSetup.setup();
} catch (Exception e) {
throw new RuntimeException(e);
}
threadManager.startAll(); threadManager.startAll();
scheduledTaskManager.startAll(); scheduledTaskManager.startAll();
globalIOHandlerRepository.setup(); globalIOHandlerRepository.setup();

View File

@@ -2,8 +2,10 @@ package cz.jzitnik;
// events/handlers/MouseMoveEventHandler.java // events/handlers/MouseMoveEventHandler.java
import java.io.IOException;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) throws IOException {
new Game().start(); new Game().start();
} }
} }

View File

@@ -1,7 +1,5 @@
package cz.jzitnik.game.setup; package cz.jzitnik.game.setup;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import cz.jzitnik.annotations.Dependency; import cz.jzitnik.annotations.Dependency;
import cz.jzitnik.annotations.injectors.InjectDependency; import cz.jzitnik.annotations.injectors.InjectDependency;
import cz.jzitnik.annotations.injectors.InjectState; import cz.jzitnik.annotations.injectors.InjectState;
@@ -9,7 +7,11 @@ import cz.jzitnik.game.GameRoom;
import cz.jzitnik.game.GameState; import cz.jzitnik.game.GameState;
import cz.jzitnik.game.Player; import cz.jzitnik.game.Player;
import cz.jzitnik.game.ResourceManager; import cz.jzitnik.game.ResourceManager;
import cz.jzitnik.utils.DependencyManager;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import tools.jackson.core.type.TypeReference;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.ObjectReader;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@@ -26,15 +28,22 @@ public class GameSetup {
@InjectDependency @InjectDependency
private ObjectMapper objectMapper; private ObjectMapper objectMapper;
@InjectDependency
private DependencyManager dependencyManager;
public void setup() throws IOException { public void setup() throws IOException {
//gameState.setScreen(new IntroScene(dependencyManager)); //gameState.setScreen(new IntroScene(dependencyManager));
List<GameRoom> rooms = objectMapper.readValue( ObjectReader roomsReader = objectMapper.readerFor(
resourceManager.getResourceAsStream("setup/rooms.yaml"), new TypeReference<List<GameRoom>>() {
new TypeReference<>() {
} }
).with(dependencyManager);
List<GameRoom> rooms = roomsReader.readValue(
resourceManager.getResourceAsStream("setup/rooms.yaml")
); );
Player player = objectMapper.readValue(resourceManager.getResourceAsStream("setup/player.yaml"), Player.class);
ObjectReader playerReader = objectMapper.readerFor(Player.class).with(dependencyManager);
Player player = playerReader.readValue(resourceManager.getResourceAsStream("setup/player.yaml"));
gameState.setCurrentRoom(rooms.getFirst()); gameState.setCurrentRoom(rooms.getFirst());
gameState.setPlayer(player); gameState.setPlayer(player);

View File

@@ -3,8 +3,6 @@ package cz.jzitnik.utils;
// Don't blame me that I'm using field injection instead of construction injection. I just like it more, leave me alone. // Don't blame me that I'm using field injection instead of construction injection. I just like it more, leave me alone.
// Yes, I know I'll suffer in the unit tests. (who said there will be any? hmmm) // Yes, I know I'll suffer in the unit tests. (who said there will be any? hmmm)
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.common.collect.ClassToInstanceMap; import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.MutableClassToInstanceMap; import com.google.common.collect.MutableClassToInstanceMap;
import cz.jzitnik.annotations.Config; import cz.jzitnik.annotations.Config;
@@ -15,8 +13,10 @@ import cz.jzitnik.annotations.injectors.InjectDependency;
import cz.jzitnik.annotations.injectors.InjectState; import cz.jzitnik.annotations.injectors.InjectState;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.reflections.Reflections; import org.reflections.Reflections;
import tools.jackson.core.JacksonException;
import tools.jackson.databind.*;
import tools.jackson.dataformat.yaml.YAMLFactory;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@@ -31,22 +31,17 @@ public class DependencyManager extends InjectableValues {
public DependencyManager(Reflections reflections) { public DependencyManager(Reflections reflections) {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
mapper.setInjectableValues(this);
data.put(ObjectMapper.class, mapper); data.put(ObjectMapper.class, mapper);
data.put(ClassLoader.class, DependencyManager.class.getClassLoader()); data.put(ClassLoader.class, DependencyManager.class.getClassLoader());
Set<Class<?>> configClasses = reflections.getTypesAnnotatedWith(Config.class); Set<Class<?>> configClasses = reflections.getTypesAnnotatedWith(Config.class);
for (Class<?> configClass : configClasses) { for (Class<?> configClass : configClasses) {
try { Config config = configClass.getAnnotation(Config.class);
Config config = configClass.getAnnotation(Config.class); assert config != null;
assert config != null; Path filePath = Path.of("config", config.value());
Path filePath = Path.of("config", config.value()); InputStream stream = DependencyManager.class.getClassLoader().getResourceAsStream(filePath.toString());
InputStream stream = DependencyManager.class.getClassLoader().getResourceAsStream(filePath.toString()); Object instance = mapper.readValue(stream, configClass);
Object instance = mapper.readValue(stream, configClass); configs.put(configClass, instance);
configs.put(configClass, instance);
} catch (IOException e) {
log.error("Failed to instantiate config class: {}", configClass.getName(), e);
}
} }
Set<Class<?>> classes = reflections.getTypesAnnotatedWith(Dependency.class); Set<Class<?>> classes = reflections.getTypesAnnotatedWith(Dependency.class);
@@ -197,10 +192,7 @@ public class DependencyManager extends InjectableValues {
} }
@Override @Override
public Object findInjectableValue(Object valueId, public Object findInjectableValue(DeserializationContext ctxt, Object valueId, BeanProperty forProperty, Object beanInstance, Boolean optional, Boolean useInput) throws JacksonException {
DeserializationContext ctxt,
BeanProperty forProperty,
Object beanInstance) throws JsonMappingException {
if (valueId instanceof Class<?> clazz) { if (valueId instanceof Class<?> clazz) {
Object dep = data.getInstance(clazz); Object dep = data.getInstance(clazz);
if (dep != null) return dep; if (dep != null) return dep;
@@ -210,6 +202,9 @@ public class DependencyManager extends InjectableValues {
if (clazz == this.getClass()) return this; if (clazz == this.getClass()) return this;
if (optional) {
return null;
}
ctxt.reportInputMismatch(forProperty, ctxt.reportInputMismatch(forProperty,
"No injectable value found for type: %s", clazz.getName()); "No injectable value found for type: %s", clazz.getName());
} else if (valueId instanceof String key) { } else if (valueId instanceof String key) {
@@ -220,14 +215,25 @@ public class DependencyManager extends InjectableValues {
if (dep.getClass().getName().equalsIgnoreCase(key)) return dep; if (dep.getClass().getName().equalsIgnoreCase(key)) return dep;
} }
if (optional) {
return null;
}
ctxt.reportInputMismatch(forProperty, ctxt.reportInputMismatch(forProperty,
"No injectable value found for key: %s", key); "No injectable value found for key: %s", key);
} else { } else if (optional) {
ctxt.reportInputMismatch(forProperty, return null;
"Unrecognized inject value id type (%s), expecting Class or String",
valueId.getClass().getName());
} }
ctxt.reportInputMismatch(forProperty,
"Unrecognized inject value id type (%s), expecting Class or String",
valueId.getClass().getName());
return null;
}
@Override
public InjectableValues snapshot() {
return null; return null;
} }
} }