2020-08-07 21:38:17 +00:00
|
|
|
package xyz.etztech.serverapi.web.api;
|
|
|
|
|
|
|
|
import com.expediagroup.graphql.annotations.GraphQLDescription;
|
|
|
|
import com.expediagroup.graphql.annotations.GraphQLName;
|
|
|
|
import org.bukkit.BanEntry;
|
|
|
|
|
|
|
|
@GraphQLName("Ban")
|
|
|
|
@GraphQLDescription("Ban GraphQL")
|
|
|
|
public class BanAPI {
|
|
|
|
private final String target;
|
|
|
|
private final String source;
|
|
|
|
private final String reason;
|
|
|
|
private final long created;
|
|
|
|
private final long expiration;
|
|
|
|
|
2021-03-16 01:54:15 +00:00
|
|
|
public BanAPI() {
|
|
|
|
this.target = "";
|
|
|
|
this.source = "";
|
|
|
|
this.reason = "";
|
|
|
|
this.created = 0;
|
|
|
|
this.expiration = 0;
|
|
|
|
}
|
|
|
|
|
2020-08-07 21:38:17 +00:00
|
|
|
public BanAPI(String target, String source, String reason, long created, long expiration) {
|
|
|
|
this.target = target;
|
|
|
|
this.source = source;
|
|
|
|
this.reason = reason;
|
|
|
|
this.created = created;
|
|
|
|
this.expiration = expiration;
|
|
|
|
}
|
|
|
|
|
|
|
|
@GraphQLName("target")
|
|
|
|
public String getTarget() {
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
|
|
|
@GraphQLName("source")
|
|
|
|
public String getSource() {
|
|
|
|
return source;
|
|
|
|
}
|
|
|
|
|
|
|
|
@GraphQLName("reason")
|
|
|
|
public String getReason() {
|
|
|
|
return reason;
|
|
|
|
}
|
|
|
|
|
|
|
|
@GraphQLName("created")
|
|
|
|
public long getCreated() {
|
|
|
|
return created;
|
|
|
|
}
|
|
|
|
|
|
|
|
@GraphQLName("expiration")
|
|
|
|
public long getExpiration() {
|
|
|
|
return expiration;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static BanAPI fromMinecraft(BanEntry entry) {
|
|
|
|
long expiration = -1;
|
|
|
|
if (entry.getExpiration() != null) {
|
|
|
|
expiration = entry.getExpiration().getTime();
|
|
|
|
}
|
|
|
|
return new BanAPI(
|
|
|
|
entry.getTarget(),
|
|
|
|
entry.getSource(),
|
|
|
|
entry.getReason(),
|
|
|
|
entry.getCreated().getTime(),
|
|
|
|
expiration
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|