mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
Initial abstraction -> ChatUser
This commit is contained in:
1 parent
03e8f4ec53
commit
97089de7ef
22 files changed
+396
-365
No files matched your search
@@ -0,0 +1,146 @@
|
||||
package net.draycia.simplechat.storage.impl;
|
||||
|
||||
import net.draycia.simplechat.SimpleChat;
|
||||
import net.draycia.simplechat.channels.ChatChannel;
|
||||
import net.draycia.simplechat.storage.ChatUser;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SimpleChatUser implements ChatUser {
|
||||
|
||||
private SimpleChat simpleChat;
|
||||
private UUID uuid;
|
||||
|
||||
private ChatChannel selectedChannel;
|
||||
private List<ChatChannel> ignoredChannels = new ArrayList<>();
|
||||
private List<UUID> ignoredUsers = new ArrayList<>();
|
||||
private boolean muted;
|
||||
private boolean shadowMuted;
|
||||
private UUID replyTarget = null;
|
||||
|
||||
public SimpleChatUser(SimpleChat simpleChat, UUID uuid) {
|
||||
this.simpleChat = simpleChat;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Audience asAudience() {
|
||||
return simpleChat.getAudiences().player(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player asPlayer() {
|
||||
return Bukkit.getPlayer(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlayer asOfflinePlayer() {
|
||||
return Bukkit.getOfflinePlayer(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return asOfflinePlayer().isOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatChannel getSelectedChannel() {
|
||||
return selectedChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedChannel(ChatChannel chatChannel) {
|
||||
this.selectedChannel = chatChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoringChannel(ChatChannel chatChannel) {
|
||||
return ignoredChannels.contains(chatChannel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoringChannel(ChatChannel chatChannel, boolean ignoring) {
|
||||
if (ignoring) {
|
||||
ignoredChannels.add(chatChannel);
|
||||
} else {
|
||||
ignoredChannels.remove(chatChannel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoringUser(UUID uuid) {
|
||||
return ignoredUsers.contains(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoringUser(ChatUser user) {
|
||||
return ignoredUsers.contains(user.getUUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoringUser(UUID uuid, boolean ignoring) {
|
||||
if (ignoring) {
|
||||
ignoredUsers.add(uuid);
|
||||
} else {
|
||||
ignoredUsers.remove(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoringUser(ChatUser user, boolean ignoring) {
|
||||
if (ignoring) {
|
||||
ignoredUsers.add(user.getUUID());
|
||||
} else {
|
||||
ignoredUsers.remove(user.getUUID());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMuted(boolean muted) {
|
||||
this.muted = muted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMuted() {
|
||||
return muted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShadowMuted(boolean shadowMuted) {
|
||||
this.shadowMuted = shadowMuted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShadowMuted() {
|
||||
return shadowMuted;
|
||||
}
|
||||
|
||||
@CheckForNull
|
||||
@Override
|
||||
public UUID getReplyTarget() {
|
||||
return replyTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTarget(UUID target) {
|
||||
this.replyTarget = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTarget(ChatUser user) {
|
||||
this.replyTarget = user.getUUID();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user