mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 08:56:04 +01:00
Implement Avatar Expedition System
Co-Authored-By: ShigemoriHakura <62388797+ShigemoriHakura@users.noreply.github.com> Co-Authored-By: KanyeWestc <104547412+KanyeWestc@users.noreply.github.com> Co-Authored-By: QAQ 天小络 <72185326+XTL676@users.noreply.github.com> Co-Authored-By: nkxingxh <25559053+nkxingxh@users.noreply.github.com> Co-Authored-By: Yazawazi <47273265+Yazawazi@users.noreply.github.com> Co-Authored-By: wuwuwu223 <81224214+wuwuwu223@users.noreply.github.com> Co-Authored-By: omg-xtao <100690902+omg-xtao@users.noreply.github.com> Co-Authored-By: Sakura <104815797+Sakura@users.noreply.github.com> Co-Authored-By: NewNeko-2022 <104819344+NewNeko-2022@users.noreply.github.com> Co-Authored-By: JimWails <30657653+JimWails@users.noreply.github.com> Co-Authored-By: buttercookies <19878609+ButterCookies@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package emu.grasscutter.game.expedition;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.server.game.GameServer;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ExpeditionManager {
|
||||
public GameServer getGameServer() {
|
||||
return gameServer;
|
||||
}
|
||||
|
||||
private final GameServer gameServer;
|
||||
|
||||
public Int2ObjectMap<List<ExpeditionRewardDataList>> getExpeditionRewardDataList() { return expeditionRewardData; }
|
||||
|
||||
private final Int2ObjectMap<List<ExpeditionRewardDataList>> expeditionRewardData;
|
||||
|
||||
public ExpeditionManager(GameServer gameServer) {
|
||||
this.gameServer = gameServer;
|
||||
this.expeditionRewardData = new Int2ObjectOpenHashMap<>();
|
||||
this.load();
|
||||
}
|
||||
|
||||
public synchronized void load() {
|
||||
try (FileReader fileReader = new FileReader(Grasscutter.getConfig().DATA_FOLDER + "ExpeditionReward.json")) {
|
||||
getExpeditionRewardDataList().clear();
|
||||
List<ExpeditionRewardInfo> banners = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, ExpeditionRewardInfo.class).getType());
|
||||
if(banners.size() > 0) {
|
||||
for (ExpeditionRewardInfo di : banners) {
|
||||
getExpeditionRewardDataList().put(di.getExpId(), di.getExpeditionRewardDataList());
|
||||
}
|
||||
Grasscutter.getLogger().info("Expedition reward successfully loaded.");
|
||||
} else {
|
||||
Grasscutter.getLogger().error("Unable to load expedition reward. Expedition reward size is 0.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("Unable to load expedition reward.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user