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:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.alttd.chat.objects;
|
||||
|
||||
import com.alttd.chat.database.Queries;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PartyUser {
|
||||
private final UUID uuid;
|
||||
private final int partyId;
|
||||
private boolean toggledChat;
|
||||
private boolean forceTp;
|
||||
|
||||
public PartyUser(UUID uuid, int partyId, boolean toggled_chat, boolean force_tp) {
|
||||
this.uuid = uuid;
|
||||
this.partyId = partyId;
|
||||
this.toggledChat = toggled_chat;
|
||||
this.forceTp = force_tp;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public int getPartyId() {
|
||||
return partyId;
|
||||
}
|
||||
|
||||
public boolean toggledChat() {
|
||||
return toggledChat;
|
||||
}
|
||||
|
||||
public void toggleChat() {
|
||||
toggledChat = !toggledChat;
|
||||
Queries.setChatState(toggledChat, uuid); //TODO: Async pls
|
||||
}
|
||||
|
||||
public boolean ForceTp() {
|
||||
return forceTp;
|
||||
}
|
||||
|
||||
public void toggleForceTp() {
|
||||
forceTp = !forceTp;
|
||||
Queries.setForceTpState(forceTp, uuid); //TODO: Async pls
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.alttd.chat.objects;
|
||||
|
||||
public class Regex {
|
||||
|
||||
private final String regex;
|
||||
private final RegexType type;
|
||||
private String replacement = "";
|
||||
|
||||
public Regex(String regex, RegexType type) {
|
||||
this.regex = regex;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Regex(String regex, RegexType type, String replacement) {
|
||||
this.regex = regex;
|
||||
this.type = type;
|
||||
this.replacement = replacement;
|
||||
}
|
||||
|
||||
public String getRegex() {
|
||||
return regex;
|
||||
}
|
||||
|
||||
public RegexType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getReplacement() {
|
||||
return replacement;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.alttd.chat.objects;
|
||||
|
||||
public enum RegexType {
|
||||
REPLACE("replace"),
|
||||
BLOCK("block");
|
||||
|
||||
private final String name;
|
||||
|
||||
RegexType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static RegexType getType(String name) {
|
||||
for (RegexType type : RegexType.values()) {
|
||||
if (type.name.equalsIgnoreCase(name)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user