mirror of
https://github.com/array-in-a-matrix/brainwine.git
synced 2025-04-02 11:11:58 -04:00
Updated dependencies and gradle wrapper
This commit is contained in:
parent
a7e0f5b36c
commit
fa9f717204
12 changed files with 59 additions and 52 deletions
|
@ -7,9 +7,7 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.apache.logging.log4j:log4j-api:2.15.0'
|
||||
implementation 'io.javalin:javalin:3.13.0'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.1'
|
||||
implementation 'io.javalin:javalin:4.6.4'
|
||||
implementation 'org.slf4j:slf4j-simple:1.8.0-beta4'
|
||||
implementation project(':shared')
|
||||
}
|
||||
|
|
|
@ -4,13 +4,15 @@ import org.apache.logging.log4j.LogManager;
|
|||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import brainwine.api.handlers.NewsRequestHandler;
|
||||
import brainwine.api.handlers.PasswordResetHandler;
|
||||
import brainwine.api.handlers.PasswordForgotHandler;
|
||||
import brainwine.api.handlers.PasswordResetHandler;
|
||||
import brainwine.api.handlers.PlayerLoginHandler;
|
||||
import brainwine.api.handlers.PlayerRegistrationHandler;
|
||||
import brainwine.api.handlers.RwcPurchaseHandler;
|
||||
import brainwine.api.handlers.SimpleExceptionHandler;
|
||||
import brainwine.shared.JsonHelper;
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.plugin.json.JavalinJackson;
|
||||
|
||||
public class GatewayService {
|
||||
|
||||
|
@ -21,7 +23,7 @@ public class GatewayService {
|
|||
logger.info("Starting GatewayService @ port {} ...", port);
|
||||
DataFetcher dataFetcher = api.getDataFetcher();
|
||||
String gameServerHost = api.getGameServerHost();
|
||||
gateway = Javalin.create().start(port);
|
||||
gateway = Javalin.create(config -> config.jsonMapper(new JavalinJackson(JsonHelper.MAPPER))).start(port);
|
||||
gateway.exception(Exception.class, new SimpleExceptionHandler());
|
||||
gateway.get("/clients", new NewsRequestHandler(api.getNews()));
|
||||
gateway.post("/players", new PlayerRegistrationHandler(dataFetcher, gameServerHost));
|
||||
|
|
|
@ -5,7 +5,9 @@ import org.apache.logging.log4j.Logger;
|
|||
|
||||
import brainwine.api.handlers.SimpleExceptionHandler;
|
||||
import brainwine.api.handlers.ZoneSearchHandler;
|
||||
import brainwine.shared.JsonHelper;
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.plugin.json.JavalinJackson;
|
||||
|
||||
/**
|
||||
* aka Zone Searcher
|
||||
|
@ -18,7 +20,7 @@ public class PortalService {
|
|||
public PortalService(Api api, int port) {
|
||||
logger.info("Starting PortalService @ port {} ...", port);
|
||||
DataFetcher dataFetcher = api.getDataFetcher();
|
||||
portal = Javalin.create().start(port);
|
||||
portal = Javalin.create(config -> config.jsonMapper(new JavalinJackson(JsonHelper.MAPPER))).start(port);
|
||||
portal.exception(Exception.class, new SimpleExceptionHandler());
|
||||
portal.get("/v1/worlds", new ZoneSearchHandler(dataFetcher));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package brainwine.api.handlers;
|
||||
|
||||
import static brainwine.api.util.ContextUtils.*;
|
||||
import static brainwine.api.util.ContextUtils.error;
|
||||
import static brainwine.api.util.ContextUtils.handleQueryParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -68,7 +69,7 @@ public class ZoneSearchHandler implements Handler {
|
|||
});
|
||||
|
||||
// Page
|
||||
int page = ctx.queryParam("page", Integer.class, "1").get();
|
||||
int page = ctx.queryParamAsClass("page", Integer.class).getOrDefault(1);
|
||||
int fromIndex = (page - 1) * PAGE_SIZE;
|
||||
int toIndex = page * PAGE_SIZE;
|
||||
ctx.json(zones.subList(fromIndex < 0 ? 0 : fromIndex > zones.size() ? zones.size() : fromIndex, toIndex > zones.size() ? zones.size() : toIndex));
|
||||
|
|
|
@ -16,8 +16,8 @@ public class ContextUtils {
|
|||
}
|
||||
|
||||
public static <T> void handleQueryParam(Context ctx, String key, Class<T> type, Consumer<T> handler) {
|
||||
Validator<T> param = ctx.queryParam(key, type);
|
||||
T value = param.getOrNull();
|
||||
Validator<T> param = ctx.queryParamAsClass(key, type);
|
||||
T value = param.getOrDefault(null);
|
||||
|
||||
if(value != null) {
|
||||
handler.accept(value);
|
||||
|
|
|
@ -7,9 +7,9 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.apache.logging.log4j:log4j-api:2.15.0'
|
||||
implementation project(':api')
|
||||
implementation project(':gameserver')
|
||||
implementation project(':shared')
|
||||
}
|
||||
|
||||
application {
|
||||
|
@ -31,6 +31,8 @@ jar {
|
|||
}
|
||||
|
||||
startScripts {
|
||||
classpath = files('$APP_HOME/lib/*')
|
||||
|
||||
doLast {
|
||||
windowsScript.text = windowsScript.text.replace('..', '')
|
||||
unixScript.text = unixScript.text.replace('..', '')
|
||||
|
|
|
@ -19,16 +19,11 @@ sourceSets {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.apache.logging.log4j:log4j-api:2.15.0'
|
||||
implementation 'org.apache.logging.log4j:log4j-core:2.15.0'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.4'
|
||||
implementation 'org.msgpack:jackson-dataformat-msgpack:0.9.0'
|
||||
implementation 'org.yaml:snakeyaml:1.27'
|
||||
implementation 'org.msgpack:jackson-dataformat-msgpack:0.9.3'
|
||||
implementation 'org.yaml:snakeyaml:1.30'
|
||||
implementation 'org.reflections:reflections:0.10.2'
|
||||
implementation 'io.netty:netty-all:4.1.58.Final'
|
||||
implementation 'io.netty:netty-all:4.1.79.Final'
|
||||
implementation 'org.mindrot:jbcrypt:0.4'
|
||||
implementation 'commons-validator:commons-validator:1.7'
|
||||
implementation 'org.apache.commons:commons-text:1.9'
|
||||
implementation project(':shared')
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ import org.msgpack.jackson.dataformat.MessagePackFactory;
|
|||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectReader;
|
||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
|
||||
import brainwine.gameserver.serialization.BlockSerializer;
|
||||
|
@ -47,20 +47,19 @@ public class Server {
|
|||
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final ThreadFactory threadFactory = new DefaultThreadFactory("netty");
|
||||
private static final ObjectMapper mapper = new ObjectMapper(new MessagePackFactory(
|
||||
MessagePack.DEFAULT_PACKER_CONFIG.withStr8FormatSupport(false)))
|
||||
.configure(SerializationFeature.WRITE_ENUMS_USING_INDEX, true)
|
||||
.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE, true)
|
||||
.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true)
|
||||
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true)
|
||||
.registerModule(new SimpleModule()
|
||||
private static final ObjectMapper mapper = JsonMapper.builder(
|
||||
new MessagePackFactory(MessagePack.DEFAULT_PACKER_CONFIG.withStr8FormatSupport(false)))
|
||||
.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX)
|
||||
.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE,DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
|
||||
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS)
|
||||
.addModule(new SimpleModule()
|
||||
.setDeserializerModifier(RequestDeserializerModifier.INSTANCE)
|
||||
.addSerializer(MessageSerializer.INSTANCE)
|
||||
.addSerializer(BlockSerializer.INSTANCE)
|
||||
.addSerializer(NetworkChunkSerializer.INSTANCE)
|
||||
.addSerializer(ItemCodeSerializer.INSTANCE));
|
||||
.addSerializer(ItemCodeSerializer.INSTANCE))
|
||||
.build();
|
||||
private static final ObjectWriter writer = mapper.writer();
|
||||
private static final ObjectReader reader = mapper.reader();
|
||||
private final List<ChannelFuture> endpoints = new ArrayList<>();
|
||||
private final Class<? extends ServerChannel> channelType;
|
||||
private final EventLoopGroup eventLoopGroup;
|
||||
|
@ -85,7 +84,7 @@ public class Server {
|
|||
Connection connection = new Connection();
|
||||
channel.pipeline().addLast("framer", new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 1024, 1, 4, 0, 0, true));
|
||||
channel.pipeline().addLast("encoder", new MessageEncoder(writer, connection));
|
||||
channel.pipeline().addLast("decoder", new RequestDecoder(reader));
|
||||
channel.pipeline().addLast("decoder", new RequestDecoder(mapper));
|
||||
channel.pipeline().addLast("handler", connection);
|
||||
}
|
||||
}).bind(port).syncUninterruptibly());
|
||||
|
|
|
@ -3,7 +3,7 @@ package brainwine.gameserver.server.pipeline;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectReader;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import brainwine.gameserver.server.NetworkRegistry;
|
||||
import brainwine.gameserver.server.Request;
|
||||
|
@ -13,10 +13,10 @@ import io.netty.handler.codec.MessageToMessageDecoder;
|
|||
|
||||
public class RequestDecoder extends MessageToMessageDecoder<ByteBuf> {
|
||||
|
||||
private final ObjectReader reader;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
public RequestDecoder(ObjectReader reader) {
|
||||
this.reader = reader;
|
||||
public RequestDecoder(ObjectMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,7 +36,7 @@ public class RequestDecoder extends MessageToMessageDecoder<ByteBuf> {
|
|||
|
||||
byte[] bytes = new byte[length];
|
||||
buf.readBytes(bytes);
|
||||
Request request = reader.readValue(bytes, type);
|
||||
Request request = mapper.readValue(bytes, type);
|
||||
out.add(request);
|
||||
}
|
||||
}
|
||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
@ -7,7 +7,12 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.1'
|
||||
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.3'
|
||||
implementation 'org.apache.logging.log4j:log4j-core:2.18.0'
|
||||
api 'com.fasterxml.jackson.core:jackson-databind:2.13.3'
|
||||
api 'org.apache.logging.log4j:log4j-api:2.18.0'
|
||||
api 'commons-validator:commons-validator:1.7'
|
||||
api 'org.apache.commons:commons-text:1.9'
|
||||
}
|
||||
|
||||
jar {
|
||||
|
|
|
@ -15,23 +15,26 @@ import com.fasterxml.jackson.databind.MapperFeature;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||
|
||||
public class JsonHelper {
|
||||
|
||||
private static final ObjectMapper mapper = new ObjectMapper()
|
||||
.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE, true)
|
||||
.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true)
|
||||
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true)
|
||||
.configure(MapperFeature.USE_BASE_TYPE_AS_DEFAULT_IMPL, true)
|
||||
.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
|
||||
private static final ObjectWriter writer = mapper.writer(CustomPrettyPrinter.INSTANCE);
|
||||
public static final ObjectMapper MAPPER = JsonMapper.builder()
|
||||
.findAndAddModules()
|
||||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE, DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
|
||||
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, MapperFeature.USE_BASE_TYPE_AS_DEFAULT_IMPL)
|
||||
.propertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE)
|
||||
.build();
|
||||
private static final ObjectWriter writer = MAPPER.writer(CustomPrettyPrinter.INSTANCE);
|
||||
|
||||
public static <T> T readValue(String string, Class<T> type) throws JsonMappingException, JsonProcessingException {
|
||||
return mapper.readValue(string, type);
|
||||
return MAPPER.readValue(string, type);
|
||||
}
|
||||
|
||||
public static <T> T readValue(File file, Class<T> type) throws JsonParseException, JsonMappingException, IOException {
|
||||
return mapper.readValue(file, type);
|
||||
return MAPPER.readValue(file, type);
|
||||
}
|
||||
|
||||
public static <T> T readValue(Object object, Class<T> type) throws JsonProcessingException {
|
||||
|
@ -39,11 +42,11 @@ public class JsonHelper {
|
|||
}
|
||||
|
||||
public static <T> T readValue(String string, TypeReference<T> type) throws JsonMappingException, JsonProcessingException {
|
||||
return mapper.readValue(string, type);
|
||||
return MAPPER.readValue(string, type);
|
||||
}
|
||||
|
||||
public static <T> T readValue(File file, TypeReference<T> type) throws IOException {
|
||||
return mapper.readValue(file, type);
|
||||
return MAPPER.readValue(file, type);
|
||||
}
|
||||
|
||||
public static <T> T readValue(Object object, TypeReference<T> type) throws JsonProcessingException {
|
||||
|
@ -51,11 +54,11 @@ public class JsonHelper {
|
|||
}
|
||||
|
||||
public static <T> T readValue(String string, Class<T> type, InjectableValues injectableValues) throws JsonMappingException, JsonProcessingException {
|
||||
return mapper.readerFor(type).with(injectableValues).readValue(string);
|
||||
return MAPPER.readerFor(type).with(injectableValues).readValue(string);
|
||||
}
|
||||
|
||||
public static <T> T readValue(File file, Class<T> type, InjectableValues injectableValues) throws JsonParseException, JsonMappingException, IOException {
|
||||
return mapper.readerFor(type).with(injectableValues).readValue(file);
|
||||
return MAPPER.readerFor(type).with(injectableValues).readValue(file);
|
||||
}
|
||||
|
||||
public static <T> T readValue(Object object, Class<T> type, InjectableValues injectableValues) throws JsonProcessingException {
|
||||
|
@ -63,7 +66,7 @@ public class JsonHelper {
|
|||
}
|
||||
|
||||
public static <T> List<T> readList(File file, Class<T> type) throws IOException {
|
||||
return mapper.readerForListOf(type).readValue(file);
|
||||
return MAPPER.readerForListOf(type).readValue(file);
|
||||
}
|
||||
|
||||
public static void writeValue(File file, Object value) throws JsonGenerationException, JsonMappingException, IOException {
|
||||
|
|
Loading…
Add table
Reference in a new issue