mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-24 01:58:25 +01:00
Cleaned up AdvancedBanData class
This commit is contained in:
parent
870b929a9e
commit
f610e014c1
@ -9,7 +9,6 @@ import com.djrapitops.plan.data.element.AnalysisContainer;
|
|||||||
import com.djrapitops.plan.data.element.InspectContainer;
|
import com.djrapitops.plan.data.element.InspectContainer;
|
||||||
import com.djrapitops.plan.data.plugin.ContainerSize;
|
import com.djrapitops.plan.data.plugin.ContainerSize;
|
||||||
import com.djrapitops.plan.data.plugin.PluginData;
|
import com.djrapitops.plan.data.plugin.PluginData;
|
||||||
import com.djrapitops.plan.data.store.keys.AnalysisKeys;
|
|
||||||
import com.djrapitops.plan.utilities.FormatUtils;
|
import com.djrapitops.plan.utilities.FormatUtils;
|
||||||
import com.djrapitops.plan.utilities.html.Html;
|
import com.djrapitops.plan.utilities.html.Html;
|
||||||
import com.djrapitops.plan.utilities.html.HtmlUtils;
|
import com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||||
@ -17,15 +16,13 @@ import com.djrapitops.plan.utilities.html.icon.Color;
|
|||||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||||
import com.djrapitops.plan.utilities.html.icon.Icons;
|
import com.djrapitops.plan.utilities.html.icon.Icons;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.UUID;
|
|
||||||
import me.leoko.advancedban.manager.PunishmentManager;
|
import me.leoko.advancedban.manager.PunishmentManager;
|
||||||
import me.leoko.advancedban.manager.UUIDManager;
|
|
||||||
import me.leoko.advancedban.utils.Punishment;
|
import me.leoko.advancedban.utils.Punishment;
|
||||||
import me.leoko.advancedban.utils.PunishmentType;
|
import me.leoko.advancedban.utils.PunishmentType;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PluginData for AdvancedBan plugin.
|
* PluginData for AdvancedBan plugin.
|
||||||
*
|
*
|
||||||
@ -45,59 +42,52 @@ public class AdvancedBanData extends PluginData {
|
|||||||
return inspectContainer;
|
return inspectContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Punishment ban = PunishmentManager.get().getBan(abUuid);
|
PunishmentManager punishmentManager = PunishmentManager.get();
|
||||||
Punishment mute = PunishmentManager.get().getMute(abUuid);
|
Punishment ban = punishmentManager.getBan(abUuid);
|
||||||
long warnings = PunishmentManager.get().getWarns(abUuid).stream().filter(warning -> !warning.isExpired()).count();
|
Punishment mute = punishmentManager.getMute(abUuid);
|
||||||
|
long warnings = punishmentManager.getWarns(abUuid).stream().filter(warning -> !warning.isExpired()).count();
|
||||||
|
|
||||||
inspectContainer.addValue(getWithIcon("Banned", Icons.BANNED), ban != null ? "Yes" : "No");
|
inspectContainer.addValue(getWithIcon("Banned", Icons.BANNED), ban != null ? "Yes" : "No");
|
||||||
inspectContainer.addValue(getWithIcon("Muted", Icon.called("bell-slash").of(Color.DEEP_ORANGE)), mute != null ? "Yes" : "No");
|
if (ban != null) {
|
||||||
|
addPunishment(inspectContainer, ban, "Permanent ban");
|
||||||
|
}
|
||||||
|
|
||||||
|
inspectContainer.addValue(getWithIcon("Muted", Icon.called("bell-slash").of(Color.DEEP_ORANGE)), mute != null ? "Yes" : "No");
|
||||||
|
if (mute != null) {
|
||||||
|
addPunishment(inspectContainer, mute, "Permanent mute");
|
||||||
|
}
|
||||||
|
|
||||||
inspectContainer.addValue(getWithIcon("Warnings", Icon.called("flag").of(Color.YELLOW)), warnings);
|
inspectContainer.addValue(getWithIcon("Warnings", Icon.called("flag").of(Color.YELLOW)), warnings);
|
||||||
|
|
||||||
if (ban != null) {
|
|
||||||
String operator = ban.getOperator();
|
|
||||||
String link = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(operator), operator);
|
|
||||||
String reason = HtmlUtils.swapColorsToSpan(ban.getReason());
|
|
||||||
long start = ban.getStart();
|
|
||||||
String end = FormatUtils.formatTimeStampYear(ban.getEnd());
|
|
||||||
|
|
||||||
if (ban.getType() == PunishmentType.BAN || ban.getType() == PunishmentType.IP_BAN) { // Permanent
|
|
||||||
end = "Permanent ban";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (operator.equals("CONSOLE")) {
|
|
||||||
link = "CONSOLE";
|
|
||||||
}
|
|
||||||
|
|
||||||
inspectContainer.addValue(" " + getWithIcon("Operator", Icon.called("user").of(Color.RED)), link);
|
|
||||||
inspectContainer.addValue(" " + getWithIcon("Date", Icon.called("calendar").of(Color.RED).of(Family.REGULAR)), FormatUtils.formatTimeStampYear(start));
|
|
||||||
inspectContainer.addValue(" " + getWithIcon("Ends", Icon.called("calendar-check").of(Color.RED).of(Family.REGULAR)), end);
|
|
||||||
inspectContainer.addValue(" " + getWithIcon("Reason", Icon.called("comment").of(Color.RED).of(Family.REGULAR)), reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mute != null) {
|
|
||||||
String operator = mute.getOperator();
|
|
||||||
String link = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(operator), operator);
|
|
||||||
String reason = HtmlUtils.swapColorsToSpan(mute.getReason());
|
|
||||||
long start = mute.getStart();
|
|
||||||
String end = FormatUtils.formatTimeStampYear(mute.getEnd());
|
|
||||||
|
|
||||||
if (mute.getType() == PunishmentType.MUTE) { // Permanent
|
|
||||||
end = "Permanent mute";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (operator.equals("CONSOLE")) {
|
|
||||||
link = "CONSOLE";
|
|
||||||
}
|
|
||||||
|
|
||||||
inspectContainer.addValue(" " + getWithIcon("Operator", Icon.called("user").of(Color.DEEP_ORANGE)), link);
|
|
||||||
inspectContainer.addValue(" " + getWithIcon("Date", Icon.called("calendar").of(Color.DEEP_ORANGE).of(Family.REGULAR)), FormatUtils.formatTimeStampYear(start));
|
|
||||||
inspectContainer.addValue(" " + getWithIcon("Ends", Icon.called("calendar-check").of(Color.DEEP_ORANGE).of(Family.REGULAR)), end);
|
|
||||||
inspectContainer.addValue(" " + getWithIcon("Reason", Icon.called("comment").of(Color.DEEP_ORANGE).of(Family.REGULAR)), reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
return inspectContainer;
|
return inspectContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addPunishment(InspectContainer inspectContainer, Punishment punishment, String identifier) {
|
||||||
|
String operator = punishment.getOperator();
|
||||||
|
String link = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(operator), operator);
|
||||||
|
String reason = HtmlUtils.swapColorsToSpan(punishment.getReason());
|
||||||
|
String start = FormatUtils.formatTimeStampYear(punishment.getStart());
|
||||||
|
String end = FormatUtils.formatTimeStampYear(punishment.getEnd());
|
||||||
|
|
||||||
|
PunishmentType type = punishment.getType();
|
||||||
|
// Permanent
|
||||||
|
if (type == PunishmentType.BAN
|
||||||
|
|| type == PunishmentType.IP_BAN
|
||||||
|
|| type == PunishmentType.MUTE
|
||||||
|
) {
|
||||||
|
end = identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operator.equals("CONSOLE")) {
|
||||||
|
link = "CONSOLE";
|
||||||
|
}
|
||||||
|
|
||||||
|
inspectContainer.addValue(" " + getWithIcon("Operator", Icon.called("user").of(Color.RED)), link);
|
||||||
|
inspectContainer.addValue(" " + getWithIcon("Date", Icon.called("calendar").of(Color.RED).of(Family.REGULAR)), start);
|
||||||
|
inspectContainer.addValue(" " + getWithIcon("Ends", Icon.called("calendar-check").of(Color.RED).of(Family.REGULAR)), end);
|
||||||
|
inspectContainer.addValue(" " + getWithIcon("Reason", Icon.called("comment").of(Color.RED).of(Family.REGULAR)), reason);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) {
|
public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) {
|
||||||
return analysisContainer;
|
return analysisContainer;
|
||||||
|
Loading…
Reference in New Issue
Block a user