mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-06-29 19:46:42 +00:00
Removal of Lombok
Lombok implementation removal. I have also gone through and replaced things with inline methods and variables, lambdas, and simplified loops down, removed unnecessary guard clauses, and overall cleaned up every single class. This took a long time, please do remember to follow proper naming conventions, don't include unnecessary guard clauses, follow exception rules and comment rules, and please PLEASE remember to use the DIAMOND OPERATOR rather than just inferring RAW TYPES!!! Thank you!!
This commit is contained in:
@ -3,32 +3,30 @@ package me.totalfreedom.totalfreedommod.punishments;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.config.IConfig;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class Punishment implements IConfig
|
||||
{
|
||||
|
||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String username = null;
|
||||
@Getter
|
||||
|
||||
private String ip = null;
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
|
||||
private String by = null;
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
|
||||
private PunishmentType type = null;
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
|
||||
private String reason = null;
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
|
||||
private Date issued_on = null;
|
||||
|
||||
public Punishment()
|
||||
@ -45,13 +43,18 @@ public class Punishment implements IConfig
|
||||
this.issued_on = new Date();
|
||||
}
|
||||
|
||||
public static SimpleDateFormat getDateFormat()
|
||||
{
|
||||
return DATE_FORMAT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFrom(ConfigurationSection cs)
|
||||
{
|
||||
this.username = cs.getString("username", null);
|
||||
this.ip = cs.getString("ip", null);
|
||||
this.by = cs.getString("by", null);
|
||||
this.type = PunishmentType.valueOf(cs.getString("type", null).toUpperCase());
|
||||
this.type = PunishmentType.valueOf(Objects.requireNonNull(cs.getString("type", null)).toUpperCase());
|
||||
this.reason = cs.getString("reason", null);
|
||||
try
|
||||
{
|
||||
@ -63,7 +66,6 @@ public class Punishment implements IConfig
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void saveTo(ConfigurationSection cs)
|
||||
{
|
||||
@ -80,4 +82,64 @@ public class Punishment implements IConfig
|
||||
{
|
||||
return username != null || ip != null;
|
||||
}
|
||||
|
||||
public String getUsername()
|
||||
{
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username)
|
||||
{
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getIp()
|
||||
{
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip)
|
||||
{
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getBy()
|
||||
{
|
||||
return by;
|
||||
}
|
||||
|
||||
public void setBy(String by)
|
||||
{
|
||||
this.by = by;
|
||||
}
|
||||
|
||||
public PunishmentType getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(PunishmentType type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getReason()
|
||||
{
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(String reason)
|
||||
{
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public Date getIssued_on()
|
||||
{
|
||||
return issued_on;
|
||||
}
|
||||
|
||||
public void setIssued_on(Date issued_on)
|
||||
{
|
||||
this.issued_on = issued_on;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.punishments;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||
@ -11,9 +12,8 @@ import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
public class PunishmentList extends FreedomService
|
||||
{
|
||||
|
||||
private final Set<Punishment> punishments = Sets.newHashSet();
|
||||
public static final String CONFIG_FILENAME = "punishments.yml";
|
||||
|
||||
private final Set<Punishment> punishments = Sets.newHashSet();
|
||||
//
|
||||
private final YamlConfig config;
|
||||
|
||||
@ -37,7 +37,7 @@ public class PunishmentList extends FreedomService
|
||||
}
|
||||
|
||||
Punishment punishment = new Punishment();
|
||||
punishment.loadFrom(config.getConfigurationSection(id));
|
||||
punishment.loadFrom(Objects.requireNonNull(config.getConfigurationSection(id)));
|
||||
|
||||
if (!punishment.isValid())
|
||||
{
|
||||
@ -55,7 +55,7 @@ public class PunishmentList extends FreedomService
|
||||
public void onStop()
|
||||
{
|
||||
saveAll();
|
||||
logger.info("Saved " + punishments.size() + " player bans");
|
||||
FLog.info("Saved " + punishments.size() + " player bans");
|
||||
}
|
||||
|
||||
public void saveAll()
|
||||
@ -113,15 +113,13 @@ public class PunishmentList extends FreedomService
|
||||
return size;
|
||||
}
|
||||
|
||||
public boolean logPunishment(Punishment punishment)
|
||||
public void logPunishment(Punishment punishment)
|
||||
{
|
||||
if (punishments.add(punishment))
|
||||
{
|
||||
saveAll();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user