Skip to content

Commit 4ba567d

Browse files
authored
fix: error when none dns records found
1 parent eaaf092 commit 4ba567d

File tree

1 file changed

+6
-4
lines changed
  • src/main/java/me/creepermaxcz/mcbots

1 file changed

+6
-4
lines changed

src/main/java/me/creepermaxcz/mcbots/Main.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ public static void main(String[] args) throws Exception {
9292
port = Integer.parseInt(split[1]);
9393
} else {
9494
Record[] records = new Lookup("_minecraft._tcp." + address, Type.SRV).run();
95-
for (Record record : records) {
96-
SRVRecord srv = (SRVRecord) record;
97-
address = srv.getTarget().toString().replaceFirst("\\.$", "");
98-
port = srv.getPort();
95+
if (records != null) {
96+
for (Record record : records) {
97+
SRVRecord srv = (SRVRecord) record;
98+
address = srv.getTarget().toString().replaceFirst("\\.$", "");
99+
port = srv.getPort();
100+
}
99101
}
100102
}
101103

0 commit comments

Comments
 (0)