2016-08-02 23:53:40 +02:00
|
|
|
package eu.univento.commons.player.mute;
|
|
|
|
|
|
|
|
import eu.univento.commons.player.uuid.NameFetcher;
|
2016-09-17 11:55:07 +02:00
|
|
|
import org.joda.time.DateTime;
|
|
|
|
import org.joda.time.Period;
|
|
|
|
import org.joda.time.format.PeriodFormatter;
|
|
|
|
import org.joda.time.format.PeriodFormatterBuilder;
|
2016-08-02 23:53:40 +02:00
|
|
|
|
2017-04-07 17:10:36 +02:00
|
|
|
import java.time.Instant;
|
2016-08-02 23:53:40 +02:00
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author joethei
|
2017-02-18 18:08:45 +01:00
|
|
|
* @version 1.0
|
2016-08-02 23:53:40 +02:00
|
|
|
*/
|
|
|
|
public class MuteData {
|
|
|
|
|
|
|
|
private MuteReason reason;
|
|
|
|
private UUID player;
|
|
|
|
private UUID muter;
|
2017-04-07 17:10:36 +02:00
|
|
|
private Instant date;
|
2016-08-02 23:53:40 +02:00
|
|
|
|
2017-04-07 17:10:36 +02:00
|
|
|
public MuteData(MuteReason reason, UUID player, UUID muter, Instant date) {
|
2016-08-02 23:53:40 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-04-07 17:10:36 +02:00
|
|
|
public Instant getDate() {
|
2016-08-02 23:53:40 +02:00
|
|
|
return date;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getMuterName() {
|
2016-09-17 11:55:07 +02:00
|
|
|
if(muter == null)
|
|
|
|
return "Auto Mute";
|
2016-08-02 23:53:40 +02:00
|
|
|
return NameFetcher.getRequest(muter);
|
|
|
|
}
|
2016-09-17 11:55:07 +02:00
|
|
|
|
|
|
|
public String getTimeTillUnmute() {
|
|
|
|
assert getDate() != null;
|
2017-04-07 17:10:36 +02:00
|
|
|
final DateTime end = new DateTime(getDate());
|
|
|
|
final DateTime now = new DateTime(Instant.now());
|
2016-09-17 11:55:07 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-08-02 23:53:40 +02:00
|
|
|
}
|