mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-12-02 21:39:45 -05:00
Add
This commit is contained in:
1 parent
c4e0174400
commit
76e5fdb692
2 files changed
+83
No files matched your search
@@ -0,0 +1,34 @@
|
||||
package de.rayzs.pat.utils;
|
||||
|
||||
public class TimeConverter {
|
||||
|
||||
private static final int MINUTES = 60, HOURS = MINUTES * 60, DAYS = HOURS * 24, WEEKS = DAYS * 7;
|
||||
|
||||
public static String calcAndGetTime(long time) {
|
||||
long upTime = (System.currentTimeMillis() - time) / 1000;
|
||||
int weeks = 0, days = 0, hours = 0, minutes = 0, seconds = (int) upTime;
|
||||
|
||||
while (seconds >= 60) {
|
||||
if (seconds >= WEEKS) {
|
||||
weeks++;
|
||||
seconds = seconds - WEEKS;
|
||||
} else if (seconds >= DAYS) {
|
||||
days++;
|
||||
seconds = seconds - DAYS;
|
||||
} else if (seconds >= HOURS) {
|
||||
hours++;
|
||||
seconds = seconds - HOURS;
|
||||
}
|
||||
minutes++;
|
||||
seconds = seconds - MINUTES;
|
||||
}
|
||||
|
||||
StringBuilder uptimeText = new StringBuilder();
|
||||
if(weeks > 0) uptimeText.append(weeks + "w, ");
|
||||
else if(days > 0) uptimeText.append(days + "d, ");
|
||||
else if(hours > 0) uptimeText.append(hours + "h, ");
|
||||
else if(minutes > 0) uptimeText.append(minutes + "m, ");
|
||||
uptimeText.append(seconds + "s");
|
||||
return uptimeText.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package de.rayzs.pat.utils.communication;
|
||||
|
||||
import de.rayzs.pat.utils.TimeConverter;
|
||||
|
||||
public class ClientInfo {
|
||||
|
||||
private final String id;
|
||||
private String name;
|
||||
|
||||
private boolean sentFeedback = false;
|
||||
private long syncTime = System.currentTimeMillis();
|
||||
|
||||
public ClientInfo(String id, String name) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean compareId(String id) {
|
||||
return this.id.equals(id);
|
||||
}
|
||||
|
||||
public void syncTime() {
|
||||
syncTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String getSyncTime() {
|
||||
return TimeConverter.calcAndGetTime(syncTime);
|
||||
}
|
||||
|
||||
public void setFeedback(boolean state) {
|
||||
this.sentFeedback = state;
|
||||
}
|
||||
|
||||
public boolean hasSentFeedback() {
|
||||
return sentFeedback;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user