mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-09 03:42:57 +08:00
Upgrade Javalin to 5.5.0 & Fix project warnings
This commit is contained in:
parent
5755aa4e6c
commit
9322c288ac
10
build.gradle
10
build.gradle
@ -79,10 +79,10 @@ dependencies {
|
||||
implementation group: 'net.java.dev.jna', name: 'jna', version: '5.10.0'
|
||||
|
||||
// Java Netty for networking.
|
||||
implementation group: 'io.netty', name: 'netty-common', version: '4.1.79.Final'
|
||||
implementation group: 'io.netty', name: 'netty-handler', version: '4.1.79.Final'
|
||||
implementation group: 'io.netty', name: 'netty-transport-native-epoll', version: '4.1.79.Final'
|
||||
implementation group: 'io.netty', name: 'netty-transport-native-kqueue', version: '4.1.79.Final'
|
||||
implementation group: 'io.netty', name: 'netty-common', version: '4.1.86.Final'
|
||||
implementation group: 'io.netty', name: 'netty-handler', version: '4.1.86.Final'
|
||||
implementation group: 'io.netty', name: 'netty-transport-native-epoll', version: '4.1.86.Final'
|
||||
implementation group: 'io.netty', name: 'netty-transport-native-kqueue', version: '4.1.86.Final'
|
||||
|
||||
// Serialization.
|
||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.0'
|
||||
@ -112,7 +112,7 @@ dependencies {
|
||||
implementation group: 'org.luaj', name: 'luaj-jse', version: '3.0.1'
|
||||
|
||||
// Java HTTP server library.
|
||||
implementation group: 'io.javalin', name: 'javalin', version: '4.6.4'
|
||||
implementation group: 'io.javalin', name: 'javalin', version: '5.5.0'
|
||||
|
||||
// Google Protocol Buffer definitions.
|
||||
// These are the raw '.proto' files.
|
||||
|
@ -1,15 +1,16 @@
|
||||
package emu.grasscutter.command;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.SERVER;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import java.util.*;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.SERVER;
|
||||
|
||||
@SuppressWarnings({"UnusedReturnValue", "unused"})
|
||||
public final class CommandMap {
|
||||
private static final int INVALID_UID = Integer.MIN_VALUE;
|
||||
@ -37,7 +38,7 @@ public final class CommandMap {
|
||||
} catch (NumberFormatException ignored) {
|
||||
var account = DatabaseHelper.getAccountByName(input);
|
||||
if (account == null) return INVALID_UID;
|
||||
var player = DatabaseHelper.getPlayerByAccount(account);
|
||||
var player = DatabaseHelper.getPlayerByAccount(account, Player.class);
|
||||
if (player == null) return INVALID_UID;
|
||||
// We will be immediately fetching the player again after this,
|
||||
// but offline vs online Player safety is more important than saving a lookup
|
||||
|
@ -1,9 +1,5 @@
|
||||
package emu.grasscutter.data;
|
||||
|
||||
import static emu.grasscutter.utils.FileUtils.getDataPath;
|
||||
import static emu.grasscutter.utils.FileUtils.getResourcePath;
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.binout.*;
|
||||
@ -33,6 +29,12 @@ import it.unimi.dsi.fastutil.Pair;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArraySet;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.val;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import javax.script.CompiledScript;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Files;
|
||||
@ -44,11 +46,10 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.script.Bindings;
|
||||
import javax.script.CompiledScript;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.val;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import static emu.grasscutter.utils.FileUtils.getDataPath;
|
||||
import static emu.grasscutter.utils.FileUtils.getResourcePath;
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
public final class ResourceLoader {
|
||||
|
||||
@ -247,10 +248,10 @@ public final class ResourceLoader {
|
||||
config.points.forEach(
|
||||
(pointId, pointData) -> {
|
||||
val scenePoint = new ScenePointEntry(sceneId, pointData);
|
||||
scenePoints.add(pointId);
|
||||
scenePoints.add((int) pointId);
|
||||
pointData.setId(pointId);
|
||||
|
||||
GameData.getScenePointIdList().add(pointId);
|
||||
GameData.getScenePointIdList().add((int) pointId);
|
||||
GameData.getScenePointEntryMap().put((sceneId << 16) + pointId, scenePoint);
|
||||
|
||||
pointData.updateDailyDungeon();
|
||||
|
@ -9,11 +9,11 @@ import emu.grasscutter.data.common.PropGrowCurve;
|
||||
import emu.grasscutter.data.excels.GadgetData;
|
||||
import emu.grasscutter.game.props.FightProperty;
|
||||
import emu.grasscutter.game.props.MonsterType;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ResourceType(name = "MonsterExcelConfigData.json", loadPriority = LoadPriority.LOW)
|
||||
@Getter
|
||||
public class MonsterData extends GameResource {
|
||||
@ -99,10 +99,9 @@ public class MonsterData extends GameResource {
|
||||
if (this.describeData == null) {
|
||||
return;
|
||||
}
|
||||
for (Entry<Integer, MonsterSpecialNameData> entry :
|
||||
GameData.getMonsterSpecialNameDataMap().entrySet()) {
|
||||
for (var entry : GameData.getMonsterSpecialNameDataMap().int2ObjectEntrySet()) {
|
||||
if (entry.getValue().getSpecialNameLabId() == this.getDescribeData().getSpecialNameLabId()) {
|
||||
this.specialNameId = entry.getKey();
|
||||
this.specialNameId = entry.getIntKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package emu.grasscutter.database;
|
||||
|
||||
import static com.mongodb.client.model.Filters.eq;
|
||||
|
||||
import com.mongodb.client.result.DeleteResult;
|
||||
import dev.morphia.query.FindOptions;
|
||||
import dev.morphia.query.Sort;
|
||||
@ -22,9 +20,12 @@ import emu.grasscutter.game.mail.Mail;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.quest.GameMainQuest;
|
||||
import emu.grasscutter.game.world.SceneGroupInstance;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.mongodb.client.model.Filters.eq;
|
||||
|
||||
public final class DatabaseHelper {
|
||||
public static Account createAccount(String username) {
|
||||
return createAccountWithUid(username, 0);
|
||||
@ -54,6 +55,7 @@ public final class DatabaseHelper {
|
||||
}
|
||||
|
||||
// Account
|
||||
@SuppressWarnings("deprecation")
|
||||
Account account = new Account();
|
||||
account.setUsername(username);
|
||||
account.setId(Integer.toString(DatabaseManager.getNextId(account)));
|
||||
|
@ -1,15 +1,14 @@
|
||||
package emu.grasscutter.game.avatar;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
|
||||
|
||||
import dev.morphia.annotations.*;
|
||||
import emu.grasscutter.GameConstants;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.binout.OpenConfigEntry;
|
||||
import emu.grasscutter.data.binout.OpenConfigEntry.SkillPointModifier;
|
||||
import emu.grasscutter.data.common.FightPropData;
|
||||
import emu.grasscutter.data.excels.*;
|
||||
import emu.grasscutter.data.excels.EquipAffixData;
|
||||
import emu.grasscutter.data.excels.ItemData.WeaponProperty;
|
||||
import emu.grasscutter.data.excels.ProudSkillData;
|
||||
import emu.grasscutter.data.excels.avatar.AvatarData;
|
||||
import emu.grasscutter.data.excels.avatar.AvatarSkillData;
|
||||
import emu.grasscutter.data.excels.avatar.AvatarSkillDepotData;
|
||||
@ -41,16 +40,19 @@ import emu.grasscutter.net.proto.TrialAvatarInfoOuterClass.TrialAvatarInfo;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.ProtoHelper;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.val;
|
||||
import org.bson.types.ObjectId;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
|
||||
|
||||
@Entity(value = "avatars", useDiscriminator = false)
|
||||
public class Avatar {
|
||||
@Transient @Getter private final Int2ObjectMap<GameItem> equips;
|
||||
@ -316,7 +318,7 @@ public class Avatar {
|
||||
var candSkillDepotId = candSkillDepotIdsList.get(candSkillDepotIndex);
|
||||
|
||||
// Sanity checks for skill depots
|
||||
val skillDepot = GameData.getAvatarSkillDepotDataMap().get(candSkillDepotId);
|
||||
val skillDepot = GameData.getAvatarSkillDepotDataMap().get((int) candSkillDepotId);
|
||||
if (skillDepot == null || skillDepot.getId() == skillDepotId) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package emu.grasscutter.game.drop;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DropInfo {
|
||||
private int monsterId;
|
||||
private List<DropData> dropDataList;
|
||||
|
@ -19,6 +19,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DropSystemLegacy extends BaseGameSystem {
|
||||
private final Int2ObjectMap<List<DropData>> dropData;
|
||||
|
||||
|
@ -107,9 +107,12 @@ public final class BlossomActivity {
|
||||
}
|
||||
generatedCount += willSpawn;
|
||||
for (int i = 0; i < willSpawn; i++) {
|
||||
var monsterData = GameData.getMonsterDataMap().get(candidateMonsters.poll());
|
||||
int level = scene.getEntityLevel(1, worldLevelOverride);
|
||||
EntityMonster entity = new EntityMonster(scene, monsterData, pos.nearby2d(4f), level);
|
||||
var entry = candidateMonsters.poll();
|
||||
if (entry == null) continue;
|
||||
|
||||
var monsterData = GameData.getMonsterDataMap().get((int) entry);
|
||||
var level = scene.getEntityLevel(1, worldLevelOverride);
|
||||
var entity = new EntityMonster(scene, monsterData, pos.nearby2d(4f), level);
|
||||
scene.addEntity(entity);
|
||||
newMonsters.add(entity);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.*;
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
@ -28,22 +29,25 @@ public final class HttpServer {
|
||||
public HttpServer() {
|
||||
this.javalin = Javalin.create(config -> {
|
||||
// Set the Javalin HTTP server.
|
||||
config.server(HttpServer::createServer);
|
||||
config.jetty.server(HttpServer::createServer);
|
||||
|
||||
// Configure encryption/HTTPS/SSL.
|
||||
config.enforceSsl = HTTP_ENCRYPTION.useEncryption;
|
||||
if (HTTP_ENCRYPTION.useEncryption)
|
||||
config.plugins.enableSslRedirects();
|
||||
|
||||
// Configure HTTP policies.
|
||||
if (HTTP_POLICIES.cors.enabled) {
|
||||
var allowedOrigins = HTTP_POLICIES.cors.allowedOrigins;
|
||||
if (allowedOrigins.length > 0)
|
||||
config.enableCorsForOrigin(allowedOrigins);
|
||||
else config.enableCorsForAllOrigins();
|
||||
config.plugins.enableCors(cors -> cors.add(corsConfig -> {
|
||||
if (allowedOrigins.length > 0)
|
||||
corsConfig.allowHost(Arrays.toString(allowedOrigins));
|
||||
else corsConfig.anyHost();
|
||||
}));
|
||||
}
|
||||
|
||||
// Configure debug logging.
|
||||
if (DISPATCH_INFO.logRequests == ServerDebugMode.ALL)
|
||||
config.enableDevLogging();
|
||||
config.plugins.enableDevLogging();
|
||||
|
||||
// Static files should be added like this https://javalin.io/documentation#static-files
|
||||
});
|
||||
|
@ -1,7 +1,5 @@
|
||||
package emu.grasscutter.server.http.handlers;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.Account;
|
||||
@ -15,6 +13,8 @@ import io.javalin.Javalin;
|
||||
import io.javalin.http.ContentType;
|
||||
import io.javalin.http.Context;
|
||||
import io.javalin.http.staticfiles.Location;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
@ -22,7 +22,8 @@ import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
/** Handles all gacha-related HTTP requests. */
|
||||
public final class GachaHandler implements Router {
|
||||
@ -144,10 +145,10 @@ public final class GachaHandler implements Router {
|
||||
javalin.get("/gacha", GachaHandler::gachaRecords);
|
||||
javalin.get("/gacha/details", GachaHandler::gachaDetails);
|
||||
|
||||
javalin._conf.addSinglePageRoot(
|
||||
"/gacha/mappings",
|
||||
gachaMappingsPath.toString(),
|
||||
Location.EXTERNAL); // TODO: This ***must*** be changed to take the Path not a String. This
|
||||
// might involve upgrading Javalin.
|
||||
javalin.cfg.staticFiles.add(cfg -> {
|
||||
cfg.hostedPath = gachaMappingsPath.toString();
|
||||
cfg.directory = "/gacha/mappings";
|
||||
cfg.location = Location.EXTERNAL;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class PacketCodexDataFullNotify extends BasePacket {
|
||||
.getUnlockedWeapon()
|
||||
.forEach(
|
||||
weapon -> {
|
||||
var codexWeapon = GameData.getCodexWeaponDataIdMap().get(weapon);
|
||||
var codexWeapon = GameData.getCodexWeaponDataIdMap().get((int) weapon);
|
||||
if (codexWeapon != null) {
|
||||
weaponTypeData
|
||||
.addCodexIdList(codexWeapon.getId())
|
||||
@ -69,7 +69,7 @@ public class PacketCodexDataFullNotify extends BasePacket {
|
||||
.getUnlockedAnimal()
|
||||
.forEach(
|
||||
(animal, amount) -> {
|
||||
var codexAnimal = GameData.getCodexAnimalDataMap().get(animal);
|
||||
var codexAnimal = GameData.getCodexAnimalDataMap().get((int) animal);
|
||||
if (codexAnimal != null) {
|
||||
animalTypeData
|
||||
.addCodexIdList(codexAnimal.getId())
|
||||
@ -82,7 +82,7 @@ public class PacketCodexDataFullNotify extends BasePacket {
|
||||
.getUnlockedMaterial()
|
||||
.forEach(
|
||||
material -> {
|
||||
var codexMaterial = GameData.getCodexMaterialDataIdMap().get(material);
|
||||
var codexMaterial = GameData.getCodexMaterialDataIdMap().get((int) material);
|
||||
if (codexMaterial != null) {
|
||||
materialTypeData
|
||||
.addCodexIdList(codexMaterial.getId())
|
||||
|
Loading…
Reference in New Issue
Block a user