fix(GachaSystem.java): Remove use of deprecated code

This commit is contained in:
KingRainbow44 2024-09-28 17:32:58 -04:00
parent 255d0a041c
commit abb3242e20
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE

View File

@ -2,7 +2,6 @@ package emu.grasscutter.game.gacha;
import static emu.grasscutter.config.Configuration.GAME_OPTIONS; import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
import com.sun.nio.file.SensitivityWatchEventModifier;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.*; import emu.grasscutter.data.*;
import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.data.common.ItemParamData;
@ -26,11 +25,14 @@ import it.unimi.dsi.fastutil.ints.*;
import java.nio.file.*; import java.nio.file.*;
import java.util.*; import java.util.*;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import lombok.Getter;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
public class GachaSystem extends BaseGameSystem { public class GachaSystem extends BaseGameSystem {
private static final int starglitterId = 221; private static final int starglitterId = 221;
private static final int stardustId = 222; private static final int stardustId = 222;
@Getter
private final Int2ObjectMap<GachaBanner> gachaBanners; private final Int2ObjectMap<GachaBanner> gachaBanners;
private WatchService watchService; private WatchService watchService;
@ -41,10 +43,6 @@ public class GachaSystem extends BaseGameSystem {
this.startWatcher(server); this.startWatcher(server);
} }
public Int2ObjectMap<GachaBanner> getGachaBanners() {
return gachaBanners;
}
public int randomRange(int min, int max) { // Both are inclusive public int randomRange(int min, int max) { // Both are inclusive
return ThreadLocalRandom.current().nextInt(max - min + 1) + min; return ThreadLocalRandom.current().nextInt(max - min + 1) + min;
} }
@ -425,18 +423,14 @@ public class GachaSystem extends BaseGameSystem {
try { try {
this.watchService = FileSystems.getDefault().newWatchService(); this.watchService = FileSystems.getDefault().newWatchService();
FileUtils.getDataUserPath("") FileUtils.getDataUserPath("")
.register( .register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);
watchService,
new WatchEvent.Kind[] {StandardWatchEventKinds.ENTRY_MODIFY},
SensitivityWatchEventModifier.HIGH);
} catch (Exception e) { } catch (Exception e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error( .error(
"Unable to load the Gacha Manager Watch Service. If ServerOptions.watchGacha is true it will not auto-reload"); "Unable to load the Gacha Manager Watch Service. If ServerOptions.watchGacha is true it will not auto-reload");
e.printStackTrace();
} }
} else { } else {
Grasscutter.getLogger().error("Cannot reinitialise watcher "); Grasscutter.getLogger().error("Cannot reinitialise watcher");
} }
} }
@ -461,8 +455,8 @@ public class GachaSystem extends BaseGameSystem {
.error( .error(
"Unable to reset Gacha Manager Watch Key. Auto-reload of banners.json will no longer work."); "Unable to reset Gacha Manager Watch Key. Auto-reload of banners.json will no longer work.");
} }
} catch (Exception e) { } catch (Exception ex) {
e.printStackTrace(); Grasscutter.getLogger().debug("Error watching Gacha Manager", ex);
} }
} }
} }