Skip to content

Commit 1226dca

Browse files
committed
ArenaConfig - more error messages when arenas fail to load
1 parent 123cab9 commit 1226dca

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

src/main/java/com/shanebeestudios/hg/plugin/configs/ArenaConfig.java

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.shanebeestudios.hg.api.game.GameBorderData;
66
import com.shanebeestudios.hg.api.game.GameRegion;
77
import com.shanebeestudios.hg.api.parsers.LocationParser;
8+
import com.shanebeestudios.hg.api.status.Status;
89
import com.shanebeestudios.hg.api.util.Pair;
910
import com.shanebeestudios.hg.api.util.Util;
1011
import com.shanebeestudios.hg.plugin.HungerGames;
@@ -84,26 +85,35 @@ public void loadAllArenas() {
8485
Util.warning("Could not create arenas directory!");
8586
}
8687
}
87-
int count = 0;
88+
int readyCount = 0;
89+
int brokenCount = 0;
8890
for (File arenaFile : this.arenaDirectory.listFiles()) {
8991
String name = arenaFile.getName();
9092
if (name.endsWith(".yml")) {
9193
YamlConfiguration arenaConfig = YamlConfiguration.loadConfiguration(arenaFile);
9294
name = name.replace(".yml", "");
93-
loadArena(arenaConfig, name);
95+
boolean isReady = loadArena(arenaConfig, name);
9496
this.fileConfigMap.put(name, Pair.of(arenaFile, arenaConfig));
95-
count++;
97+
if (isReady) {
98+
readyCount++;
99+
} else {
100+
brokenCount++;
101+
}
96102
}
97103
}
98-
if (count > 0) {
99-
Util.log("- <aqua>%s <grey>arenas have been <green>successfully loaded!", count);
100-
} else {
104+
if (readyCount == 0 && brokenCount == 0) {
101105
Util.log("- <red>No Arenas found. <grey>Time to create some!");
102106
}
107+
if (readyCount > 0) {
108+
Util.log("- <aqua>%s <grey>arenas have been <green>successfully loaded!", readyCount);
109+
}
110+
if (brokenCount > 0) {
111+
Util.log("- <aqua>%s <grey>arenas have <red>failed to successfully loaded!", brokenCount);
112+
}
103113
}
104114

105115
@SuppressWarnings("DataFlowIssue")
106-
public void loadArena(FileConfiguration arenaConfig, String arenaName) {
116+
public boolean loadArena(FileConfiguration arenaConfig, String arenaName) {
107117
boolean isReady = true;
108118
List<Location> spawns = new ArrayList<>();
109119
Location lobbysign = null;
@@ -229,7 +239,14 @@ public void loadArena(FileConfiguration arenaConfig, String arenaName) {
229239
arenaName, world.getName());
230240
Util.debug(exception);
231241
}
232-
Util.log("- Loaded arena <white>'<aqua>%s<white>'<grey>", arenaName);
242+
if (gameArenaData.getStatus() == Status.BROKEN) {
243+
Util.warning("<red>Failed to properly initiate arena <white>'<aqua>%s<white>'<grey>", arenaName);
244+
Util.warning("Run <white>'<aqua>/hg debug %s<white>' <yellow>to check the status of the arena.", arenaName);
245+
isReady = false;
246+
} else {
247+
Util.log("- Loaded arena <white>'<aqua>%s<white>'<grey>", arenaName);
248+
}
249+
return isReady;
233250
}
234251

235252
/**

0 commit comments

Comments
 (0)