mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 08:56:04 +01:00
Convert to the far superior config system
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
package emu.grasscutter.game.gacha;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.net.proto.GachaInfoOuterClass.GachaInfo;
|
||||
import emu.grasscutter.net.proto.GachaUpInfoOuterClass.GachaUpInfo;
|
||||
|
||||
import static emu.grasscutter.Configuration.*;
|
||||
|
||||
public class GachaBanner {
|
||||
private int gachaType;
|
||||
private int scheduleId;
|
||||
@@ -95,15 +96,11 @@ public class GachaBanner {
|
||||
public GachaInfo toProto() {
|
||||
return toProto("");
|
||||
}
|
||||
|
||||
public GachaInfo toProto(String sessionKey) {
|
||||
String record = "http" + (Grasscutter.getConfig().getDispatchOptions().FrontHTTPS ? "s" : "") + "://"
|
||||
+ (Grasscutter.getConfig().getDispatchOptions().PublicIp.isEmpty() ?
|
||||
Grasscutter.getConfig().getDispatchOptions().Ip :
|
||||
Grasscutter.getConfig().getDispatchOptions().PublicIp)
|
||||
+ ":"
|
||||
+ Integer.toString(Grasscutter.getConfig().getDispatchOptions().PublicPort == 0 ?
|
||||
Grasscutter.getConfig().getDispatchOptions().Port :
|
||||
Grasscutter.getConfig().getDispatchOptions().PublicPort)
|
||||
String record = "http" + (DISPATCH_INFO.encryption.useInRouting ? "s" : "") + "://"
|
||||
+ lr(DISPATCH_INFO.accessAddress, DISPATCH_INFO.bindAddress) + ":"
|
||||
+ lr(DISPATCH_INFO.accessPort, DISPATCH_INFO.bindPort)
|
||||
+ "/gacha?s=" + sessionKey + "&gachaType=" + gachaType;
|
||||
// Grasscutter.getLogger().info("record = " + record);
|
||||
GachaInfo.Builder info = GachaInfo.newBuilder()
|
||||
|
||||
@@ -34,20 +34,22 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import static emu.grasscutter.Configuration.*;
|
||||
|
||||
public class GachaManager {
|
||||
private final GameServer server;
|
||||
private final Int2ObjectMap<GachaBanner> gachaBanners;
|
||||
private GetGachaInfoRsp cachedProto;
|
||||
WatchService watchService;
|
||||
|
||||
private int[] yellowAvatars = new int[] {1003, 1016, 1042, 1035, 1041};
|
||||
private int[] yellowWeapons = new int[] {11501, 11502, 12501, 12502, 13502, 13505, 14501, 14502, 15501, 15502};
|
||||
private int[] purpleAvatars = new int[] {1006, 1014, 1015, 1020, 1021, 1023, 1024, 1025, 1027, 1031, 1032, 1034, 1036, 1039, 1043, 1044, 1045, 1048, 1053, 1055, 1056, 1064};
|
||||
private int[] purpleWeapons = new int[] {11401, 11402, 11403, 11405, 12401, 12402, 12403, 12405, 13401, 13407, 14401, 14402, 14403, 14409, 15401, 15402, 15403, 15405};
|
||||
private int[] blueWeapons = new int[] {11301, 11302, 11306, 12301, 12302, 12305, 13303, 14301, 14302, 14304, 15301, 15302, 15304};
|
||||
private final int[] yellowAvatars = new int[] {1003, 1016, 1042, 1035, 1041};
|
||||
private final int[] yellowWeapons = new int[] {11501, 11502, 12501, 12502, 13502, 13505, 14501, 14502, 15501, 15502};
|
||||
private final int[] purpleAvatars = new int[] {1006, 1014, 1015, 1020, 1021, 1023, 1024, 1025, 1027, 1031, 1032, 1034, 1036, 1039, 1043, 1044, 1045, 1048, 1053, 1055, 1056, 1064};
|
||||
private final int[] purpleWeapons = new int[] {11401, 11402, 11403, 11405, 12401, 12402, 12403, 12405, 13401, 13407, 14401, 14402, 14403, 14409, 15401, 15402, 15403, 15405};
|
||||
private final int[] blueWeapons = new int[] {11301, 11302, 11306, 12301, 12302, 12305, 13303, 14301, 14302, 14304, 15301, 15302, 15304};
|
||||
|
||||
private static int starglitterId = 221;
|
||||
private static int stardustId = 222;
|
||||
private static final int starglitterId = 221;
|
||||
private static final int stardustId = 222;
|
||||
|
||||
public GachaManager(GameServer server) {
|
||||
this.server = server;
|
||||
@@ -73,7 +75,7 @@ public class GachaManager {
|
||||
}
|
||||
|
||||
public synchronized void load() {
|
||||
try (FileReader fileReader = new FileReader(Grasscutter.getConfig().DATA_FOLDER + "Banners.json")) {
|
||||
try (FileReader fileReader = new FileReader(DATA("Banners.json"))) {
|
||||
getGachaBanners().clear();
|
||||
List<GachaBanner> banners = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, GachaBanner.class).getType());
|
||||
if(banners.size() > 0) {
|
||||
@@ -242,15 +244,9 @@ public class GachaManager {
|
||||
} else {
|
||||
// Is weapon
|
||||
switch (itemData.getRankLevel()) {
|
||||
case 5:
|
||||
addStarglitter = 10;
|
||||
break;
|
||||
case 4:
|
||||
addStarglitter = 2;
|
||||
break;
|
||||
case 3:
|
||||
addStardust = 15;
|
||||
break;
|
||||
case 5 -> addStarglitter = 10;
|
||||
case 4 -> addStarglitter = 2;
|
||||
case 3 -> addStardust = 15;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,7 +286,7 @@ public class GachaManager {
|
||||
if(this.watchService == null) {
|
||||
try {
|
||||
this.watchService = FileSystems.getDefault().newWatchService();
|
||||
Path path = new File(Grasscutter.getConfig().DATA_FOLDER).toPath();
|
||||
Path path = new File(DATA_FOLDER).toPath();
|
||||
path.register(watchService, new WatchEvent.Kind[]{StandardWatchEventKinds.ENTRY_MODIFY}, SensitivityWatchEventModifier.HIGH);
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("Unable to load the Gacha Manager Watch Service. If ServerOptions.watchGacha is true it will not auto-reload");
|
||||
@@ -303,7 +299,7 @@ public class GachaManager {
|
||||
|
||||
@Subscribe
|
||||
public synchronized void watchBannerJson(GameServerTickEvent tickEvent) {
|
||||
if(Grasscutter.getConfig().getGameServerOptions().WatchGacha) {
|
||||
if(GAME_OPTIONS.watchGachaConfig) {
|
||||
try {
|
||||
WatchKey watchKey = watchService.take();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user