feat: Server selector

This commit is contained in:
2026-02-01 15:16:44 +01:00
parent fc14e4081d
commit ac5a96eb19
46 changed files with 792 additions and 86 deletions

View File

@@ -12,6 +12,44 @@
<artifactId>server</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.42</version>
</path>
</annotationProcessorPaths>
<source>25</source>
<target>25</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>cz.jzitnik.server.Main</mainClass>
<classpathScope>compile</classpathScope>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>cz.jzitnik</groupId>

View File

@@ -11,7 +11,7 @@ import org.reflections.Reflections;
import java.util.*;
public class Main {
static void main() throws DeploymentException {
public static void main(String[] args) throws DeploymentException {
GlobalContext globalContext = new GlobalContext();
AppContext.set(globalContext);

View File

@@ -1,14 +1,32 @@
package cz.jzitnik.server.events.handlers;
import cz.jzitnik.common.models.player.PlayerCreation;
import cz.jzitnik.common.socket.messages.game.creation.CreateGame;
import cz.jzitnik.common.socket.messages.game.creation.CreateGameResponse;
import cz.jzitnik.server.annotations.EventHandler;
import cz.jzitnik.server.context.GlobalContext;
import cz.jzitnik.server.events.AbstractEventHandler;
import cz.jzitnik.server.game.Client;
import lombok.RequiredArgsConstructor;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.ObjectReader;
import tools.jackson.dataformat.yaml.YAMLFactory;
@RequiredArgsConstructor
@EventHandler(CreateGame.class)
public class CreateGameHandler extends AbstractEventHandler<CreateGame> {
private final GlobalContext globalContext;
@Override
public void handle(CreateGame event, Client client) {
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
String pass = "nevim"; // TODO: Generate
ObjectReader playerReader = objectMapper.readerFor(PlayerCreation.class);
PlayerCreation player = playerReader.readValue(getClass().getClassLoader().getResourceAsStream("setup/player.yaml"));
CreateGameResponse gameResponse = new CreateGameResponse(pass, player);
client.session().sendMessage(gameResponse);
}
}

View File

@@ -1,7 +1,6 @@
package cz.jzitnik.server.socket;
import cz.jzitnik.common.socket.SocketMessage;
import cz.jzitnik.common.socket.messages.Test;
import jakarta.websocket.Session;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

View File

@@ -0,0 +1,11 @@
playerCords:
x: 90
y: 100
collider:
start:
x: 0
y: 52
end:
x: 44
y: 78