Added queries to store regex, ignored users, parties, and party users

Added Party and party user class with all database functionality
NOTE: Regex doesn't have a way to be added or edited through the plugin atm. I don't know if that's needed since doing it through minecraft seems a bit odd, we could maybe add it to some discord bot or something in the future though
This commit is contained in:
2021-05-11 19:21:48 +02:00
parent e7f399010f
commit 21a15c3817
6 changed files with 535 additions and 0 deletions
@@ -0,0 +1,80 @@
package com.alttd.chat.objects;
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<PartyUser> 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<PartyUser> partyUsers) {
this.partyUsers.addAll(partyUsers);
}
public void addUser(PartyUser partyUser) {
this.partyUsers.add(partyUser);
Queries.addUser(partyUser);
}
public void removeUser(PartyUser 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<PartyUser> getPartyUsers() {
return partyUsers;
}
public void setPartyUsers(ArrayList<PartyUser> partyUsers) {
this.partyUsers = partyUsers;
}
}