2021-01-03 07:21:15 +00:00
|
|
|
package dev.plex.punishment;
|
2020-11-06 18:51:47 +00:00
|
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
import com.google.gson.Gson;
|
2022-02-05 23:14:23 +00:00
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
2020-11-10 02:47:03 +00:00
|
|
|
import java.util.Date;
|
2020-11-06 18:51:47 +00:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.UUID;
|
2022-02-07 03:43:37 +00:00
|
|
|
|
|
|
|
import com.google.gson.GsonBuilder;
|
|
|
|
import dev.plex.util.adapter.LocalDateTimeAdapter;
|
2022-01-27 21:23:01 +00:00
|
|
|
import lombok.Getter;
|
|
|
|
import lombok.Setter;
|
2020-11-06 18:51:47 +00:00
|
|
|
|
|
|
|
@Getter
|
|
|
|
@Setter
|
|
|
|
public class Punishment
|
|
|
|
{
|
|
|
|
private final UUID punished;
|
|
|
|
private final UUID punisher;
|
|
|
|
|
|
|
|
private final List<String> IPS;
|
|
|
|
|
|
|
|
private String punishedUsername;
|
|
|
|
|
|
|
|
private PunishmentType type;
|
|
|
|
private String reason;
|
|
|
|
private boolean customTime;
|
2022-02-05 23:14:23 +00:00
|
|
|
private LocalDateTime endDate;
|
2020-11-06 18:51:47 +00:00
|
|
|
|
|
|
|
public Punishment(UUID punished, UUID punisher)
|
|
|
|
{
|
|
|
|
this.punished = punished;
|
|
|
|
this.punisher = punisher;
|
|
|
|
this.IPS = Lists.newArrayList();
|
|
|
|
|
|
|
|
this.punishedUsername = "";
|
|
|
|
this.type = null;
|
|
|
|
this.reason = "";
|
|
|
|
this.customTime = false;
|
2020-11-10 02:47:03 +00:00
|
|
|
this.endDate = null;
|
2020-11-06 18:51:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String toJSON()
|
|
|
|
{
|
2022-02-07 03:43:37 +00:00
|
|
|
return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeAdapter()).create().toJson(this);
|
2020-11-06 18:51:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static Punishment fromJson(String json)
|
|
|
|
{
|
2022-02-07 03:43:37 +00:00
|
|
|
return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeAdapter()).create().fromJson(json, Punishment.class);
|
2020-11-06 18:51:47 +00:00
|
|
|
}
|
|
|
|
}
|