Updated to 1.21 by switching to cosmos
This commit is contained in:
@@ -3,7 +3,7 @@ package com.alttd.chat.objects;
|
||||
import com.alttd.chat.database.Queries;
|
||||
import com.alttd.chat.objects.channels.Channel;
|
||||
import com.alttd.chat.util.Utility;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -13,20 +13,20 @@ import java.util.stream.Collectors;
|
||||
public class ChatUser {
|
||||
private final UUID uuid; // player uuid
|
||||
private int partyId; // the party they are in
|
||||
private Channel toggledChannel;
|
||||
private final Channel toggledChannel;
|
||||
private String name; // the nickname, doesn't need to be saved with the chatuser object, could be saved but we can get it from the nicknamesview
|
||||
private Component displayName; // the nickname, doesn't need to be saved with the chatuser object, could be saved but we can get it from the nicknamesview
|
||||
// private Component prefix; // doesn't need saving, we get this from luckperms
|
||||
// private Component staffPrefix; // doesn't need saving, we get this from luckperms
|
||||
// private Component prefixAll; // doesn't need saving, we get this from luckperms
|
||||
private ComponentLike displayName; // the nickname, doesn't need to be saved with the chatuser object, could be saved but we can get it from the nicknamesview
|
||||
// private Component prefix; // doesn't need saving, we get this from luckperms
|
||||
// private Component staffPrefix; // doesn't need saving, we get this from luckperms
|
||||
// private Component prefixAll; // doesn't need saving, we get this from luckperms
|
||||
//private boolean toggleGc; // should be saved, this toggles if the player can see and use global chat
|
||||
private String replyTarget; // reply target for use in /msg i don't mind setting this to null on login, feedback?
|
||||
private String replyContinueTarget; // reply target for use in /c
|
||||
private long gcCooldown; // the time when they last used gc, is used for the cooldown, i wouldn't save this, but setting this to the login time means they can't use gc for 30 seconds after logging in
|
||||
private boolean spy;
|
||||
private List<Mail> mails; // mails aren't finalized yet, so for now a table sender, reciever, sendtime, readtime(if emtpy mail isn't read yet?, could also do a byte to control this), the actual message
|
||||
private List<UUID> ignoredPlayers; // a list of UUID, a new table non unique, where one is is the player select * from ignores where ignoredby = thisplayer? where the result is the uuid of the player ignored by this player?
|
||||
private List<UUID> ignoredBy; // a list of UUID, same table as above but select * from ignores where ignored = thisplayer? result should be the other user that ignored this player?
|
||||
private final List<Mail> mails; // mails aren't finalized yet, so for now a table sender, reciever, sendtime, readtime(if emtpy mail isn't read yet?, could also do a byte to control this), the actual message
|
||||
private final List<UUID> ignoredPlayers; // a list of UUID, a new table non unique, where one is is the player select * from ignores where ignoredby = thisplayer? where the result is the uuid of the player ignored by this player?
|
||||
private final List<UUID> ignoredBy; // a list of UUID, same table as above but select * from ignores where ignored = thisplayer? result should be the other user that ignored this player?
|
||||
private boolean isMuted;
|
||||
|
||||
public ChatUser(UUID uuid, int partyId, Channel toggledChannel) {
|
||||
@@ -40,10 +40,10 @@ public class ChatUser {
|
||||
}
|
||||
setDisplayName(name);
|
||||
|
||||
// prefix = Utility.getPrefix(uuid, true); // TODO we need to update this, so cache and update when needed or always request it?
|
||||
// staffPrefix = Utility.getStaffPrefix(uuid);
|
||||
//
|
||||
// prefixAll = Utility.getPrefix(uuid, false);
|
||||
// prefix = Utility.getPrefix(uuid, true); // TODO we need to update this, so cache and update when needed or always request it?
|
||||
// staffPrefix = Utility.getStaffPrefix(uuid);
|
||||
//
|
||||
// prefixAll = Utility.getPrefix(uuid, false);
|
||||
|
||||
replyTarget = "";
|
||||
replyContinueTarget = "";
|
||||
@@ -71,12 +71,7 @@ public class ChatUser {
|
||||
return toggledChannel;
|
||||
}
|
||||
|
||||
public void setToggledChannel(Channel channel) {
|
||||
toggledChannel = channel;
|
||||
Queries.setToggledChannel(toggledChannel, uuid); //TODO: Async pls - no CompleteableFuture<>!
|
||||
}
|
||||
|
||||
public Component getDisplayName() {
|
||||
public ComponentLike getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@@ -84,17 +79,17 @@ public class ChatUser {
|
||||
this.displayName = Utility.applyColor(displayName);
|
||||
}
|
||||
|
||||
public Component getPrefix() {
|
||||
public ComponentLike getPrefix() {
|
||||
//return prefix;
|
||||
return Utility.getPrefix(uuid, true); // No longer cache this data
|
||||
}
|
||||
|
||||
public Component getStaffPrefix() {
|
||||
public ComponentLike getStaffPrefix() {
|
||||
//return staffPrefix;
|
||||
return Utility.getStaffPrefix(uuid);
|
||||
}
|
||||
|
||||
public Component getPrefixAll() {
|
||||
public ComponentLike getPrefixAll() {
|
||||
//return prefixAll;
|
||||
return Utility.getPrefix(uuid, false);
|
||||
}
|
||||
@@ -145,10 +140,6 @@ public class ChatUser {
|
||||
return ignoredBy;
|
||||
}
|
||||
|
||||
public void addIgnoredBy(UUID uuid) {
|
||||
ignoredBy.add(uuid);
|
||||
}
|
||||
|
||||
public long getGcCooldown() {
|
||||
return gcCooldown;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.managers.RegexManager;
|
||||
import com.alttd.chat.util.Utility;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -16,7 +16,7 @@ public class EmoteList {
|
||||
|
||||
public static final Map<UUID, EmoteList> emoteLists = new HashMap<>();
|
||||
public static final int pageSize = 7;
|
||||
// public static int pages = RegexManager.getEmoteFilters().size() / pageSize;// TODO reload this when config is reloaded.
|
||||
// public static int pages = RegexManager.getEmoteFilters().size() / pageSize;// TODO reload this when config is reloaded.
|
||||
|
||||
public static EmoteList getEmoteList(UUID uuid) {
|
||||
synchronized (emoteLists) {
|
||||
@@ -25,22 +25,23 @@ public class EmoteList {
|
||||
}
|
||||
|
||||
private int page;
|
||||
public Component showEmotePage() {
|
||||
|
||||
public ComponentLike showEmotePage() {
|
||||
int startIndex = page * pageSize;
|
||||
int pages = RegexManager.getEmoteFilters().size() / pageSize;
|
||||
int endIndex = Math.min(startIndex + pageSize, RegexManager.getEmoteFilters().size());
|
||||
TagResolver placeholders = TagResolver.resolver(
|
||||
Placeholder.unparsed("page", String.valueOf(page)),
|
||||
Placeholder.unparsed("pages", String.valueOf(pages))
|
||||
);
|
||||
Component list = Utility.parseMiniMessage(Config.EMOTELIST_HEADER, placeholders);
|
||||
);
|
||||
Component list = Utility.parseMiniMessage(Config.EMOTELIST_HEADER, placeholders).asComponent();
|
||||
|
||||
for (int i = startIndex; i < endIndex; i++) {
|
||||
ChatFilter emote = RegexManager.getEmoteFilters().get(i);
|
||||
TagResolver emotes = TagResolver.resolver(
|
||||
Placeholder.parsed("regex", emote.getRegex()),
|
||||
Placeholder.parsed("emote", emote.getReplacement())
|
||||
);
|
||||
);
|
||||
list = list.append(Utility.parseMiniMessage(Config.EMOTELIST_ITEM, emotes));
|
||||
}
|
||||
list = list.append(Utility.parseMiniMessage(Config.EMOTELIST_FOOTER, placeholders));
|
||||
@@ -60,5 +61,4 @@ public class EmoteList {
|
||||
this.page = Math.max(page - 1, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,6 @@ package com.alttd.chat.objects;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.intellij.lang.annotations.RegExp;
|
||||
|
||||
import javax.annotation.RegEx;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ModifiableString {
|
||||
private Component text;
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package com.alttd.chat.objects;
|
||||
|
||||
import com.alttd.chat.util.Utility;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PartyUser {
|
||||
|
||||
protected UUID uuid;
|
||||
protected Component displayName;
|
||||
protected ComponentLike displayName;
|
||||
protected String playerName;
|
||||
|
||||
public PartyUser(UUID uuid, String displayName, String playerName) {
|
||||
this(uuid, Utility.applyColor(displayName), playerName);
|
||||
}
|
||||
|
||||
public PartyUser(UUID uuid, Component displayName, String playerName) {
|
||||
public PartyUser(UUID uuid, ComponentLike displayName, String playerName) {
|
||||
this.uuid = uuid;
|
||||
this.displayName = displayName;
|
||||
this.playerName = playerName;
|
||||
@@ -25,7 +25,7 @@ public class PartyUser {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public Component getDisplayName() {
|
||||
public ComponentLike getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user