merge api into velocity

This commit is contained in:
len
2021-05-24 10:10:02 +02:00
parent 0d0c4a13e5
commit d8a4490358
19 changed files with 54 additions and 83 deletions
@@ -0,0 +1,32 @@
package com.alttd.chat.data;
public class ChatFilter {
private final String regex;
private final FilterType type;
private String replacement = "";
public ChatFilter(String regex, FilterType type) {
this.regex = regex;
this.type = type;
}
public ChatFilter(String regex, FilterType type, String replacement) {
this.regex = regex;
this.type = type;
this.replacement = replacement;
}
public String getRegex() {
return regex;
}
public FilterType getType() {
return type;
}
public String getReplacement() {
return replacement;
}
}
@@ -0,0 +1,125 @@
package com.alttd.chat.data;
import com.alttd.chat.database.Queries;
import com.alttd.chat.util.Utility;
import java.util.LinkedList;
import java.util.UUID;
public class ChatUser {
private final UUID uuid;
private final int partyId;
private boolean toggledPartyChat;
private boolean forceTp;
private String displayName;
private String prefix;
private String staffPrefix;
private String prefixAll;
private boolean toggleGc;
private UUID replyTarget;
private LinkedList<Mail> mails;
public ChatUser(UUID uuid, int partyId, boolean toggled_chat, boolean force_tp, boolean toggle_Gc) {
this.uuid = uuid;
this.partyId = partyId;
this.toggledPartyChat = toggled_chat;
this.forceTp = force_tp;
displayName = Queries.getNickname(uuid);
if (displayName == null) {
displayName = Utility.getDisplayName(uuid);
}
prefix = Utility.getPrefix(uuid, true);
staffPrefix = Utility.getStaffPrefix(uuid);
prefixAll = Utility.getPrefix(uuid, false);
toggleGc = toggle_Gc;
replyTarget = null;
mails = new LinkedList<>(); // todo load mails
}
public UUID getUuid() {
return uuid;
}
public int getPartyId() {
return partyId;
}
public boolean toggledPartyChat() {
return toggledPartyChat;
}
public void togglePartyChat() {
toggledPartyChat = !toggledPartyChat;
Queries.setPartyChatState(toggledPartyChat, uuid); //TODO: Async pls - no CompleteableFuture<>!
}
public boolean ForceTp() {
return forceTp;
}
public void toggleForceTp() {
forceTp = !forceTp;
Queries.setForceTpState(forceTp, uuid); //TODO: Async pls - no CompleteableFuture<>!
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getPrefix() {
return prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
public String getStaffPrefix() {
return staffPrefix;
}
public void setStaffPrefix(String staffPrefix) {
this.staffPrefix = staffPrefix;
}
public String getPrefixAll() {
return prefixAll;
}
public void setPrefixAll(String prefixAll) {
this.prefixAll = prefixAll;
}
public void toggleGc() {
toggleGc = !toggleGc;
}
public boolean isGcOn() {
return toggleGc;
}
public UUID getReplyTarget() {
return replyTarget;
}
public void setReplyTarget(UUID replyTarget) {
this.replyTarget = replyTarget;
}
public LinkedList<Mail> getMails() {
return mails;
}
public void addMail(Mail mail) {
mails.add(mail);
}
}
@@ -0,0 +1,22 @@
package com.alttd.chat.data;
public enum FilterType {
REPLACE("replace"),
BLOCK("block");
private final String name;
FilterType(String name) {
this.name = name;
}
public static FilterType getType(String name) {
for (FilterType type : FilterType.values()) {
if (type.name.equalsIgnoreCase(name)) {
return type;
}
}
return null;
}
}
@@ -0,0 +1,54 @@
package com.alttd.chat.data;
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;
}
}
@@ -0,0 +1,80 @@
package com.alttd.chat.data;
import com.alttd.chat.database.Queries;
import java.util.ArrayList;
import java.util.UUID;
public class Party {
private final int partyId;
private UUID ownerUuid;
private String partyName;
private String partyPassword;
private ArrayList<ChatUser> partyUsers; //TODO might need to be a map?
public Party(int partyId, UUID ownerUuid, String partyName, String partyPassword) {
this.partyId = partyId;
this.ownerUuid = ownerUuid;
this.partyName = partyName;
this.partyPassword = partyPassword;
partyUsers = new ArrayList<>();
}
public void addUser(ArrayList<ChatUser> partyUsers) {
this.partyUsers.addAll(partyUsers);
}
public void addUser(ChatUser partyUser) {
this.partyUsers.add(partyUser);
Queries.addUser(partyUser);
}
public void removeUser(ChatUser partyUser) {
partyUsers.remove(partyUser);
Queries.removeUser(partyUser.getUuid());
}
public int getPartyId() {
return partyId;
}
public UUID getOwnerUuid() {
return ownerUuid;
}
public void setOwnerUuid(UUID ownerUuid) {
this.ownerUuid = ownerUuid;
Queries.setPartyOwner(ownerUuid, partyId); //TODO: Async pls
}
public String getPartyName() {
return partyName;
}
public void setPartyName(String partyName) {
this.partyName = partyName;
Queries.setPartyName(partyName, partyId); //TODO: Async pls
}
public String getPartyPassword() {
return partyPassword;
}
public void setPartyPassword(String partyPassword) {
this.partyPassword = partyPassword;
Queries.setPartyPassword(partyPassword, partyId); //TODO: Async pls
}
public boolean hasPartyPassword() {
return !partyPassword.isEmpty();
}
public ArrayList<ChatUser> getPartyUsers() {
return partyUsers;
}
public void setPartyUsers(ArrayList<ChatUser> partyUsers) {
this.partyUsers = partyUsers;
}
}