chore: Updated dependencies
This commit is contained in:
44
pom.xml
44
pom.xml
@@ -8,7 +8,6 @@
|
||||
<artifactId>game</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -89,14 +88,9 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.38</version>
|
||||
<version>1.18.42</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.8.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
@@ -107,25 +101,31 @@
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>31.1-jre</version>
|
||||
<version>33.5.0-jre</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<groupId>tools.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.18.2</version>
|
||||
<version>3.0.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<groupId>tools.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||
<version>2.18.2</version>
|
||||
<version>3.0.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.2</version>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<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>
|
||||
</dependency>
|
||||
|
||||
@@ -134,21 +134,18 @@
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>2.0.17</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.5.18</version>
|
||||
<version>1.5.25</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.trilarion</groupId>
|
||||
<artifactId>java-vorbis-support</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.esotericsoftware</groupId>
|
||||
<artifactId>kryo</artifactId>
|
||||
<version>5.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.googlecode.lanterna</groupId>
|
||||
@@ -159,13 +156,13 @@
|
||||
<dependency>
|
||||
<groupId>org.bytedeco</groupId>
|
||||
<artifactId>javacv-platform</artifactId>
|
||||
<version>1.5.10</version>
|
||||
<version>1.5.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bytedeco</groupId>
|
||||
<artifactId>ffmpeg-platform</artifactId>
|
||||
<version>6.1.1-1.5.10</version>
|
||||
<version>7.1.1-1.5.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -173,6 +170,7 @@
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>be.tarsos.dsp</groupId>
|
||||
<artifactId>jvm</artifactId>
|
||||
|
||||
@@ -8,6 +8,8 @@ import cz.jzitnik.utils.ScheduledTaskManager;
|
||||
import cz.jzitnik.utils.ThreadManager;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Game {
|
||||
private final DependencyManager dependencyManager = new DependencyManager(new Reflections("cz.jzitnik"));
|
||||
|
||||
@@ -22,14 +24,10 @@ public class Game {
|
||||
@InjectDependency
|
||||
private GlobalIOHandlerRepository globalIOHandlerRepository;
|
||||
|
||||
public void start() {
|
||||
public void start() throws IOException {
|
||||
dependencyManager.inject(this);
|
||||
|
||||
try {
|
||||
gameSetup.setup();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
threadManager.startAll();
|
||||
scheduledTaskManager.startAll();
|
||||
globalIOHandlerRepository.setup();
|
||||
|
||||
@@ -2,8 +2,10 @@ package cz.jzitnik;
|
||||
|
||||
// events/handlers/MouseMoveEventHandler.java
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws IOException {
|
||||
new Game().start();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
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.injectors.InjectDependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
@@ -9,7 +7,11 @@ import cz.jzitnik.game.GameRoom;
|
||||
import cz.jzitnik.game.GameState;
|
||||
import cz.jzitnik.game.Player;
|
||||
import cz.jzitnik.game.ResourceManager;
|
||||
import cz.jzitnik.utils.DependencyManager;
|
||||
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.util.List;
|
||||
@@ -26,15 +28,22 @@ public class GameSetup {
|
||||
@InjectDependency
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@InjectDependency
|
||||
private DependencyManager dependencyManager;
|
||||
|
||||
public void setup() throws IOException {
|
||||
//gameState.setScreen(new IntroScene(dependencyManager));
|
||||
|
||||
List<GameRoom> rooms = objectMapper.readValue(
|
||||
resourceManager.getResourceAsStream("setup/rooms.yaml"),
|
||||
new TypeReference<>() {
|
||||
ObjectReader roomsReader = objectMapper.readerFor(
|
||||
new TypeReference<List<GameRoom>>() {
|
||||
}
|
||||
).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.setPlayer(player);
|
||||
|
||||
@@ -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.
|
||||
// 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.MutableClassToInstanceMap;
|
||||
import cz.jzitnik.annotations.Config;
|
||||
@@ -15,8 +13,10 @@ import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -31,22 +31,17 @@ public class DependencyManager extends InjectableValues {
|
||||
|
||||
public DependencyManager(Reflections reflections) {
|
||||
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
|
||||
mapper.setInjectableValues(this);
|
||||
data.put(ObjectMapper.class, mapper);
|
||||
data.put(ClassLoader.class, DependencyManager.class.getClassLoader());
|
||||
|
||||
Set<Class<?>> configClasses = reflections.getTypesAnnotatedWith(Config.class);
|
||||
for (Class<?> configClass : configClasses) {
|
||||
try {
|
||||
Config config = configClass.getAnnotation(Config.class);
|
||||
assert config != null;
|
||||
Path filePath = Path.of("config", config.value());
|
||||
InputStream stream = DependencyManager.class.getClassLoader().getResourceAsStream(filePath.toString());
|
||||
Object instance = mapper.readValue(stream, configClass);
|
||||
configs.put(configClass, instance);
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to instantiate config class: {}", configClass.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
Set<Class<?>> classes = reflections.getTypesAnnotatedWith(Dependency.class);
|
||||
@@ -197,10 +192,7 @@ public class DependencyManager extends InjectableValues {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object findInjectableValue(Object valueId,
|
||||
DeserializationContext ctxt,
|
||||
BeanProperty forProperty,
|
||||
Object beanInstance) throws JsonMappingException {
|
||||
public Object findInjectableValue(DeserializationContext ctxt, Object valueId, BeanProperty forProperty, Object beanInstance, Boolean optional, Boolean useInput) throws JacksonException {
|
||||
if (valueId instanceof Class<?> clazz) {
|
||||
Object dep = data.getInstance(clazz);
|
||||
if (dep != null) return dep;
|
||||
@@ -210,6 +202,9 @@ public class DependencyManager extends InjectableValues {
|
||||
|
||||
if (clazz == this.getClass()) return this;
|
||||
|
||||
if (optional) {
|
||||
return null;
|
||||
}
|
||||
ctxt.reportInputMismatch(forProperty,
|
||||
"No injectable value found for type: %s", clazz.getName());
|
||||
} else if (valueId instanceof String key) {
|
||||
@@ -220,14 +215,25 @@ public class DependencyManager extends InjectableValues {
|
||||
if (dep.getClass().getName().equalsIgnoreCase(key)) return dep;
|
||||
}
|
||||
|
||||
if (optional) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ctxt.reportInputMismatch(forProperty,
|
||||
"No injectable value found for key: %s", key);
|
||||
} else {
|
||||
} else if (optional) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ctxt.reportInputMismatch(forProperty,
|
||||
"Unrecognized inject value id type (%s), expecting Class or String",
|
||||
valueId.getClass().getName());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InjectableValues snapshot() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user