Plex/src/main/java/dev/plex/banning/Ban.java

62 lines
1.5 KiB
Java
Raw Normal View History

2021-01-03 07:21:15 +00:00
package dev.plex.banning;
import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Id;
import dev.morphia.annotations.IndexOptions;
import dev.morphia.annotations.Indexed;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang.RandomStringUtils;
import java.util.Date;
import java.util.UUID;
@Getter
@Setter
@Entity(value = "bans", useDiscriminator = false)
public class Ban
{
2021-01-03 07:21:15 +00:00
public Ban()
{
}
@Setter(AccessLevel.NONE)
@Id
private String id;
@Setter(AccessLevel.NONE)
@Indexed(options = @IndexOptions(unique = true))
2021-01-03 07:21:15 +00:00
private UUID uuid;
@Indexed // have the banner be indexed in the future to get bans issued by a person
private UUID banner;
private String ip;
private String reason;
private Date endDate;
private boolean active;
2021-01-03 07:21:15 +00:00
public Ban(UUID uuid, UUID banner, String ip, String reason, Date endDate)
{
this.uuid = uuid;
this.id = uuid.toString().substring(0, 8) + "-" + RandomStringUtils.randomAlphabetic(6);
this.banner = banner;
this.ip = ip;
this.reason = reason;
this.endDate = endDate;
this.active = true;
}
2020-11-10 02:49:51 +00:00
public Ban(String id, UUID uuid, UUID banner, String ip, String reason, Date endDate)
{
this.uuid = uuid;
this.id = id;
this.banner = banner;
2020-11-10 02:49:51 +00:00
this.ip = ip;
this.reason = reason;
this.endDate = endDate;
this.active = true;
}
}