mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 04:32:53 +08:00
Move chest rewards to new data format
This commit is contained in:
parent
fe4e599014
commit
a8f38ad995
@ -2,8 +2,11 @@ package emu.grasscutter.game.world;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.DataLoader;
|
||||
import emu.grasscutter.server.game.GameServer;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
@ -23,13 +26,13 @@ public class WorldDataManager {
|
||||
}
|
||||
|
||||
public synchronized void load(){
|
||||
try {
|
||||
try(InputStream is = DataLoader.load("ChestReward.json", false); InputStreamReader isr = new InputStreamReader(is)) {
|
||||
List<ChestReward> chestReward = Grasscutter.getGsonFactory().fromJson(
|
||||
Files.readString(Path.of(DATA("ChestReward.json"))),
|
||||
isr,
|
||||
TypeToken.getParameterized(List.class, ChestReward.class).getType());
|
||||
|
||||
chestReward.forEach(reward ->
|
||||
reward.getObjNames().forEach(name -> chestRewardMap.put(name, reward)));
|
||||
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("Unable to load chest reward config.", e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user