2020-08-13 20:14:25 +00:00
|
|
|
package serverapi
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Ban is a Minecraft ban
|
|
|
|
type Ban struct {
|
|
|
|
Target string `json:"target"`
|
|
|
|
Source string `jso:"source"`
|
|
|
|
Reason string `json:"reason"`
|
|
|
|
Created int64 `json:"created"`
|
|
|
|
Expiration int64 `json:"expiration"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreatedTime is Created converted to a time.Time
|
|
|
|
func (b *Ban) CreatedTime() time.Time {
|
|
|
|
return time.Unix(b.Created/1000, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExpirationTime is Expiration converted to a time.Time
|
|
|
|
func (b *Ban) ExpirationTime() time.Time {
|
|
|
|
return time.Unix(b.Expiration/1000, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bans gets a list of Ban from a ServerAPI instance
|
2020-08-13 20:41:14 +00:00
|
|
|
func (c *Client) Bans() (bans Ban, err error) {
|
2020-08-13 20:14:25 +00:00
|
|
|
return bans, c.json(fmt.Sprintf("%s/bans", c.Endpoint), &bans)
|
|
|
|
}
|