mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 17:05:20 +01:00
Convert to the far superior config system
This commit is contained in:
@@ -8,6 +8,8 @@ import emu.grasscutter.server.game.GameServer;
|
||||
import java.io.FileReader;
|
||||
import java.util.List;
|
||||
|
||||
import static emu.grasscutter.Configuration.*;
|
||||
|
||||
public class TowerScheduleManager {
|
||||
private final GameServer gameServer;
|
||||
|
||||
@@ -23,9 +25,8 @@ public class TowerScheduleManager {
|
||||
private TowerScheduleConfig towerScheduleConfig;
|
||||
|
||||
public synchronized void load(){
|
||||
try (FileReader fileReader = new FileReader(Grasscutter.getConfig().DATA_FOLDER + "TowerSchedule.json")) {
|
||||
try (FileReader fileReader = new FileReader(DATA("TowerSchedule.json"))) {
|
||||
towerScheduleConfig = Grasscutter.getGsonFactory().fromJson(fileReader, TowerScheduleConfig.class);
|
||||
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("Unable to load tower schedule config.", e);
|
||||
}
|
||||
@@ -40,6 +41,7 @@ public class TowerScheduleManager {
|
||||
if(data == null){
|
||||
Grasscutter.getLogger().error("Could not get current tower schedule data by config:{}", towerScheduleConfig);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -51,28 +53,31 @@ public class TowerScheduleManager {
|
||||
var entranceFloors = getCurrentTowerScheduleData().getEntranceFloorId();
|
||||
var scheduleFloors = getScheduleFloors();
|
||||
var nextId = 0;
|
||||
|
||||
// find in entrance floors first
|
||||
for(int i=0;i<entranceFloors.size()-1;i++){
|
||||
if(floorId == entranceFloors.get(i)){
|
||||
nextId = entranceFloors.get(i+1);
|
||||
}
|
||||
}
|
||||
|
||||
if(floorId == entranceFloors.get(entranceFloors.size()-1)){
|
||||
nextId = scheduleFloors.get(0);
|
||||
}
|
||||
|
||||
if(nextId != 0){
|
||||
return nextId;
|
||||
}
|
||||
|
||||
// find in schedule floors
|
||||
for(int i=0;i<scheduleFloors.size()-1;i++){
|
||||
for(int i=0; i < scheduleFloors.size() - 1; i++){
|
||||
if(floorId == scheduleFloors.get(i)){
|
||||
nextId = scheduleFloors.get(i+1);
|
||||
nextId = scheduleFloors.get(i + 1);
|
||||
}
|
||||
}
|
||||
return nextId;
|
||||
}return nextId;
|
||||
}
|
||||
|
||||
public Integer getLastEntranceFloor() {
|
||||
return getCurrentTowerScheduleData().getEntranceFloorId().get(getCurrentTowerScheduleData().getEntranceFloorId().size()-1);
|
||||
return getCurrentTowerScheduleData().getEntranceFloorId().get(getCurrentTowerScheduleData().getEntranceFloorId().size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user