77 lines
2.1 KiB
Java
77 lines
2.1 KiB
Java
/*
|
|
* Copyright (c) 2017 univento.eu - All rights reserved
|
|
* You are not allowed to use, distribute or modify this code
|
|
*/
|
|
|
|
package eu.univento.commons.player.mute;
|
|
|
|
import eu.univento.commons.player.uuid.NameFetcher;
|
|
import org.joda.time.DateTime;
|
|
import org.joda.time.Period;
|
|
import org.joda.time.format.PeriodFormatter;
|
|
import org.joda.time.format.PeriodFormatterBuilder;
|
|
|
|
import java.time.Instant;
|
|
import java.util.UUID;
|
|
|
|
/**
|
|
* @author joethei
|
|
* @version 1.0
|
|
*/
|
|
public class MuteData {
|
|
|
|
private MuteReason reason;
|
|
private UUID player;
|
|
private UUID muter;
|
|
private Instant date;
|
|
|
|
public MuteData(MuteReason reason, UUID player, UUID muter, Instant date) {
|
|
this.reason = reason;
|
|
this.player = player;
|
|
this.muter = muter;
|
|
this.date = date;
|
|
}
|
|
|
|
public MuteReason getReason() {
|
|
return reason;
|
|
}
|
|
|
|
public UUID getPlayer() {
|
|
return player;
|
|
}
|
|
|
|
public UUID getMuter() {
|
|
return muter;
|
|
}
|
|
|
|
public Instant getDate() {
|
|
return date;
|
|
}
|
|
|
|
public String getMuterName() {
|
|
if(muter == null)
|
|
return "Auto Mute";
|
|
return NameFetcher.getRequest(muter);
|
|
}
|
|
|
|
public String getTimeTillUnmute() {
|
|
assert getDate() != null;
|
|
final DateTime end = new DateTime(getDate());
|
|
final DateTime now = new DateTime(Instant.now());
|
|
Period period = new Period(now, end);
|
|
PeriodFormatter formatter = new PeriodFormatterBuilder().printZeroAlways().minimumPrintedDigits(2)
|
|
.appendYears().appendSuffix(" Jahr", " Jahre")
|
|
.appendSeparator(", ")
|
|
.appendMonths().appendSuffix(" Monat", " Monate")
|
|
.appendSeparator(", ")
|
|
.appendDays().appendSuffix(" Tag", " Tage")
|
|
.appendSeparator(" und ")
|
|
.appendHours().appendSuffix(" Stunde", " Stunden")
|
|
.appendMinutes().appendSuffix(" Minute", " Minuten")
|
|
.appendSeconds().appendSuffix(" Sekunde", " Sekunden")
|
|
.toFormatter();
|
|
|
|
return period.toString(formatter);
|
|
}
|
|
|
|
} |