Add base for Mailing
This commit is contained in:
@@ -2,9 +2,12 @@ package com.alttd.chat.managers;
|
||||
|
||||
import com.alttd.chat.database.Queries;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import com.alttd.chat.objects.Mail;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class ChatUserManager {
|
||||
|
||||
@@ -28,4 +31,10 @@ public final class ChatUserManager {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Mail> getUnReadMail(ChatUser user) {
|
||||
return user.getMails().stream()
|
||||
.filter(Mail::isUnRead)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.alttd.chat.objects;
|
||||
import com.alttd.chat.database.Queries;
|
||||
import com.alttd.chat.util.Utility;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChatUser {
|
||||
@@ -15,8 +16,13 @@ public class ChatUser {
|
||||
private String staffPrefix;
|
||||
private String prefixAll;
|
||||
private boolean toggleGc;
|
||||
private UUID replytarget;
|
||||
private UUID replyTarget;
|
||||
|
||||
private LinkedList<Mail> mails;
|
||||
|
||||
/**
|
||||
* Not all of the objects are relevant to proxy or server, so the saving should only update if the value has been changed?
|
||||
*/
|
||||
public ChatUser(UUID uuid, int partyId, boolean toggled_chat, boolean force_tp, boolean toggle_Gc) {
|
||||
this.uuid = uuid;
|
||||
this.partyId = partyId;
|
||||
@@ -34,7 +40,8 @@ public class ChatUser {
|
||||
prefixAll = prefix + staffPrefix; //TODO test what this does cus I barely understand lp api
|
||||
// a boolean is lighter then a permission check, it's what I'd suggest doing here
|
||||
toggleGc = toggle_Gc;//Utility.checkPermission(uuid, "chat.gc"); //TODO put the actual permission here, I don't know what it is...
|
||||
replytarget = null;
|
||||
replyTarget = null;
|
||||
mails = new LinkedList<>(); // todo load mails
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
@@ -103,11 +110,15 @@ public class ChatUser {
|
||||
return toggleGc;
|
||||
}
|
||||
|
||||
public UUID getReplytarget() {
|
||||
return replytarget;
|
||||
public UUID getReplyTarget() {
|
||||
return replyTarget;
|
||||
}
|
||||
|
||||
public void setReplytarget(UUID replytarget) {
|
||||
this.replytarget = replytarget;
|
||||
public void setReplyTarget(UUID replyTarget) {
|
||||
this.replyTarget = replyTarget;
|
||||
}
|
||||
|
||||
public LinkedList<Mail> getMails() {
|
||||
return mails;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.alttd.chat.objects;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Mail {
|
||||
|
||||
private final UUID uuid; // the player
|
||||
private final UUID sender; // the sender
|
||||
private boolean read;
|
||||
private final long sendTime; // any other option for this? does the db store recordcreation and edit time?
|
||||
private long readTime; // any other option for this?
|
||||
private final String message; // do we want staff to edit this after being send but being unread?
|
||||
|
||||
public Mail(UUID player, UUID sender, Boolean read, long sendTime, long readTime, String message) {
|
||||
this.uuid = player;
|
||||
this.sender = sender;
|
||||
this.read = read;
|
||||
this.sendTime = sendTime;
|
||||
this.readTime = readTime;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public UUID getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public boolean isUnRead() {
|
||||
return read;
|
||||
}
|
||||
|
||||
public void setRead(boolean read) {
|
||||
this.read = read;
|
||||
}
|
||||
|
||||
public long getSendTime() {
|
||||
return sendTime;
|
||||
}
|
||||
|
||||
public long getReadTime() {
|
||||
return readTime;
|
||||
}
|
||||
|
||||
public void setReadTime(long readTime) {
|
||||
this.readTime = readTime;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -51,12 +51,11 @@ public class Utility {
|
||||
}
|
||||
|
||||
public static String getDisplayName(UUID uuid) {
|
||||
// todo add a <T> PlayerWrapper<T> @Destro
|
||||
/*ProxyServer proxy = ChatPlugin.getPlugin().getProxy();
|
||||
if (proxy.getPlayer(uuid).isEmpty()) return "";
|
||||
Player player = proxy.getPlayer(uuid).get();
|
||||
return player.getUsername();*/
|
||||
return "";
|
||||
StringBuilder prefix = new StringBuilder();
|
||||
LuckPerms luckPerms = ChatAPI.get().getLuckPerms();
|
||||
User user = luckPerms.getUserManager().getUser(uuid);
|
||||
if(user == null) return "";
|
||||
return user.getUsername();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user