Skip to content

Commit f759dd1

Browse files
authored
Add SkipReadinessCheck flag (#94)
1 parent 6773a87 commit f759dd1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

java_status.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ type statusCmd struct {
3232
UseProxy bool `usage:"supports contacting Bungeecord when proxy_protocol enabled"`
3333
ProxyVersion byte `usage:"version of PROXY protocol to use" default:"1"`
3434

35+
SkipReadinessCheck bool `usage:"returns success when pinging a server without player info, or with a max player count of 0"`
36+
3537
ShowPlayerCount bool `usage:"show just the online player count"`
3638
}
3739

@@ -90,7 +92,7 @@ func (c *statusCmd) Execute(_ context.Context, _ *flag.FlagSet, args ...interfac
9092
// While server is starting up it will answer pings, but respond with empty JSON object.
9193
// As such, we'll sanity check the max players value to see if a zero-value has been
9294
// provided for info.
93-
if info.Players.Max == 0 {
95+
if info.Players.Max == 0 && !c.SkipReadinessCheck {
9496

9597
_, _ = fmt.Fprintf(os.Stderr, "server not ready %s:%d", c.Host, c.Port)
9698
return errors.New("server not ready")
@@ -127,7 +129,7 @@ func (c *statusCmd) ExecuteServerListPing() subcommands.ExitStatus {
127129
return err
128130
}
129131

130-
if response.MaxPlayers == "0" {
132+
if response.MaxPlayers == "0" && !c.SkipReadinessCheck {
131133
return errors.New("server not ready")
132134
}
133135

@@ -176,7 +178,7 @@ func (c *statusCmd) ExecuteMcUtilPing(logger *zap.Logger) subcommands.ExitStatus
176178
response := hs.Properties.Infos()
177179
logger.Debug("mcutils ping returned", zap.Any("properties", response))
178180

179-
if response.Players.Max == 0 {
181+
if response.Players.Max == 0 && !c.SkipReadinessCheck {
180182
return errors.New("server not ready")
181183
}
182184

0 commit comments

Comments
 (0)