Rename DiscordPlayer to DiscordUser
About time It's been like that since I started this project in 2016 It's not representing an in-game player, it's representing a DC user
This commit is contained in:
parent
02e05e360e
commit
222d393420
13 changed files with 32 additions and 32 deletions
|
@ -8,7 +8,7 @@ import buttondevteam.discordplugin.exceptions.ExceptionListenerModule
|
|||
import buttondevteam.discordplugin.fun.FunModule
|
||||
import buttondevteam.discordplugin.listeners.{CommonListeners, MCListener}
|
||||
import buttondevteam.discordplugin.mcchat.MinecraftChatModule
|
||||
import buttondevteam.discordplugin.mcchat.sender.{DiscordPlayer, DiscordSenderBase}
|
||||
import buttondevteam.discordplugin.mcchat.sender.{DiscordUser, DiscordSenderBase}
|
||||
import buttondevteam.discordplugin.mccommands.DiscordMCCommand
|
||||
import buttondevteam.discordplugin.role.GameRoleModule
|
||||
import buttondevteam.discordplugin.util.{DPState, Timings}
|
||||
|
@ -179,7 +179,7 @@ import scala.jdk.OptionConverters.*
|
|||
}
|
||||
CommonListeners.register(DiscordPlugin.dc.getEventDispatcher)
|
||||
TBMCCoreAPI.RegisterEventsForExceptions(new MCListener, this)
|
||||
TBMCCoreAPI.RegisterUserClass(classOf[DiscordPlayer], () => new DiscordPlayer)
|
||||
TBMCCoreAPI.RegisterUserClass(classOf[DiscordUser], () => new DiscordUser)
|
||||
ChromaGamerBase.addConverter {
|
||||
case dsender: DiscordSenderBase => Some(dsender.getChromaUser).toJava
|
||||
case _ => None.toJava
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package buttondevteam.discordplugin.announcer
|
||||
|
||||
import buttondevteam.discordplugin.mcchat.sender.DiscordPlayer
|
||||
import buttondevteam.discordplugin.mcchat.sender.DiscordUser
|
||||
import buttondevteam.discordplugin.{DPUtils, DiscordPlugin}
|
||||
import buttondevteam.lib.TBMCCoreAPI
|
||||
import buttondevteam.lib.architecture.{Component, ComponentMetadata}
|
||||
|
@ -74,7 +74,7 @@ import scala.collection.mutable
|
|||
val reddituserclass = ChromaGamerBase.getTypeForFolder("reddit")
|
||||
if (reddituserclass != null) {
|
||||
val user = ChromaGamerBase.getUser(author, reddituserclass)
|
||||
val id = user.getConnectedID(classOf[DiscordPlayer])
|
||||
val id = user.getConnectedID(classOf[DiscordUser])
|
||||
if (id != null) author = "<@" + id + ">"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package buttondevteam.discordplugin.commands
|
||||
|
||||
import buttondevteam.discordplugin.mcchat.sender.DiscordPlayer
|
||||
import buttondevteam.discordplugin.mcchat.sender.DiscordUser
|
||||
import buttondevteam.lib.chat.{Command2, CommandClass}
|
||||
import buttondevteam.lib.player.{TBMCPlayer, TBMCPlayerBase}
|
||||
import com.google.common.collect.HashBiMap
|
||||
|
@ -34,7 +34,7 @@ import org.bukkit.entity.Player
|
|||
return true
|
||||
}
|
||||
val pl = TBMCPlayerBase.getPlayer(p.getUniqueId, classOf[TBMCPlayer])
|
||||
val dp = pl.getAs(classOf[DiscordPlayer])
|
||||
val dp = pl.getAs(classOf[DiscordUser])
|
||||
if (dp != null && author.getId.asString == dp.getDiscordID) {
|
||||
sender.event.reply("You already have this account connected.").subscribe()
|
||||
return true
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package buttondevteam.discordplugin.commands
|
||||
|
||||
import buttondevteam.discordplugin.DiscordPlugin
|
||||
import buttondevteam.discordplugin.mcchat.sender.DiscordPlayer
|
||||
import buttondevteam.discordplugin.mcchat.sender.DiscordUser
|
||||
import buttondevteam.lib.chat.{Command2, CommandClass}
|
||||
import buttondevteam.lib.player.ChromaGamerBase
|
||||
import buttondevteam.lib.player.ChromaGamerBase.InfoTarget
|
||||
|
@ -23,7 +23,7 @@ class UserinfoCommand extends ICommand2DC {
|
|||
sender.sendMessage("An error occurred.")
|
||||
return true
|
||||
}
|
||||
val dp = ChromaGamerBase.getUser(target.getId.asString, classOf[DiscordPlayer])
|
||||
val dp = ChromaGamerBase.getUser(target.getId.asString, classOf[DiscordUser])
|
||||
val uinfo = new StringBuilder("User info for ").append(target.getUsername).append(":\n")
|
||||
uinfo.append(dp.getInfo(InfoTarget.Discord))
|
||||
sender.sendMessage(uinfo.toString)
|
||||
|
|
|
@ -4,7 +4,7 @@ import buttondevteam.discordplugin.commands.ConnectCommand
|
|||
import buttondevteam.discordplugin.mcchat.MinecraftChatModule
|
||||
import buttondevteam.discordplugin.util.DPState
|
||||
import buttondevteam.discordplugin.DiscordPlugin
|
||||
import buttondevteam.discordplugin.mcchat.sender.DiscordPlayer
|
||||
import buttondevteam.discordplugin.mcchat.sender.DiscordUser
|
||||
import buttondevteam.lib.ScheduledServerRestartEvent
|
||||
import buttondevteam.lib.player.TBMCPlayerGetInfoEvent
|
||||
import discord4j.common.util.Snowflake
|
||||
|
@ -23,7 +23,7 @@ class MCListener extends Listener {
|
|||
}
|
||||
|
||||
@EventHandler def onGetInfo(e: TBMCPlayerGetInfoEvent): Unit = {
|
||||
Option(DiscordPlugin.SafeMode).filterNot(identity).flatMap(_ => Option(e.getPlayer.getAs(classOf[DiscordPlayer])))
|
||||
Option(DiscordPlugin.SafeMode).filterNot(identity).flatMap(_ => Option(e.getPlayer.getAs(classOf[DiscordUser])))
|
||||
.flatMap(dp => Option(dp.getDiscordID)).filter(_.nonEmpty)
|
||||
.map(Snowflake.of).flatMap(id => DiscordPlugin.dc.getUserById(id).onErrorResume(_ => Mono.empty).blockOptional().toScala)
|
||||
.map(user => {
|
||||
|
|
|
@ -4,7 +4,7 @@ import buttondevteam.core.component.channel.{Channel, ChatRoom}
|
|||
import buttondevteam.discordplugin.*
|
||||
import buttondevteam.discordplugin.ChannelconBroadcast.ChannelconBroadcast
|
||||
import buttondevteam.discordplugin.commands.{Command2DCSender, ICommand2DC}
|
||||
import buttondevteam.discordplugin.mcchat.sender.{DiscordConnectedPlayer, DiscordPlayer}
|
||||
import buttondevteam.discordplugin.mcchat.sender.{DiscordConnectedPlayer, DiscordUser}
|
||||
import buttondevteam.lib.TBMCSystemChatEvent
|
||||
import buttondevteam.lib.architecture.config.IConfigData
|
||||
import buttondevteam.lib.chat.{Command2, CommandClass}
|
||||
|
@ -115,7 +115,7 @@ class ChannelconCommand(private val module: MinecraftChatModule) extends IComman
|
|||
return true
|
||||
}
|
||||
val author = message.getAuthor.get
|
||||
val dp: DiscordPlayer = ChromaGamerBase.getUser(author.getId.asString, classOf[DiscordPlayer])
|
||||
val dp: DiscordUser = ChromaGamerBase.getUser(author.getId.asString, classOf[DiscordUser])
|
||||
val chp: TBMCPlayer = dp.getAs(classOf[TBMCPlayer])
|
||||
if (chp == null) {
|
||||
DPUtils.reply(message, channel, "you need to connect your Minecraft account. On the main server in " + DPUtils.botmention + " do " + DiscordPlugin.getPrefix + "connect <MCname>").subscribe()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package buttondevteam.discordplugin.mcchat
|
||||
|
||||
import buttondevteam.discordplugin.commands.{Command2DCSender, ICommand2DC}
|
||||
import buttondevteam.discordplugin.mcchat.sender.DiscordPlayer
|
||||
import buttondevteam.discordplugin.mcchat.sender.DiscordUser
|
||||
import buttondevteam.discordplugin.{DPUtils, DiscordPlugin}
|
||||
import buttondevteam.lib.chat.{Command2, CommandClass}
|
||||
import buttondevteam.lib.player.ChromaGamerBase
|
||||
|
@ -25,7 +25,7 @@ class MCChatCommand(private val module: MinecraftChatModule) extends ICommand2DC
|
|||
sender.sendMessage("This command can only be issued in a direct message with the bot.")
|
||||
return true
|
||||
}
|
||||
val user: DiscordPlayer = ChromaGamerBase.getUser(sender.author.getId.asString, classOf[DiscordPlayer])
|
||||
val user: DiscordUser = ChromaGamerBase.getUser(sender.author.getId.asString, classOf[DiscordUser])
|
||||
val mcchat: Boolean = !user.isMinecraftChatEnabled
|
||||
MCChatPrivate.privateMCChat(channel, mcchat, sender.author, user)
|
||||
sender.sendMessage("Minecraft chat " +
|
||||
|
|
|
@ -3,7 +3,7 @@ package buttondevteam.discordplugin.mcchat
|
|||
import buttondevteam.core.ComponentManager
|
||||
import buttondevteam.discordplugin.*
|
||||
import buttondevteam.discordplugin.DPUtils.SpecExtensions
|
||||
import buttondevteam.discordplugin.mcchat.sender.{DiscordPlayer, DiscordSender, DiscordSenderBase}
|
||||
import buttondevteam.discordplugin.mcchat.sender.{DiscordUser, DiscordSender, DiscordSenderBase}
|
||||
import buttondevteam.lib.*
|
||||
import buttondevteam.lib.chat.{ChatMessage, TBMCChatAPI}
|
||||
import buttondevteam.lib.player.TBMCPlayer
|
||||
|
@ -100,7 +100,7 @@ class MCChatListener(val module: MinecraftChatModule) extends Listener {
|
|||
case player: TBMCPlayer =>
|
||||
DPUtils.embedWithHead(ecs, authorPlayer, e.getUser.getName,
|
||||
if (url.nonEmpty) url + "?type=minecraft&id=" + player.getUniqueId else null)
|
||||
case dsender: DiscordPlayer =>
|
||||
case dsender: DiscordUser =>
|
||||
ecs.author(authorPlayer,
|
||||
if (url.nonEmpty) url + "?type=discord&id=" + dsender.getDiscordID else null,
|
||||
dsender.getDiscordUser.getAvatarUrl)
|
||||
|
@ -139,7 +139,7 @@ class MCChatListener(val module: MinecraftChatModule) extends Listener {
|
|||
// Checks if the given channel is different than where the message was sent from
|
||||
// Or if it was from MC
|
||||
val isdifferentchannel: Predicate[Snowflake] = {
|
||||
id => !e.getUser.isInstanceOf[DiscordPlayer] || e.getUser.asInstanceOf[DiscordSender].getChannel.getId.asLong != id.asLong
|
||||
id => !e.getUser.isInstanceOf[DiscordUser] || e.getUser.asInstanceOf[DiscordSender].getChannel.getId.asLong != id.asLong
|
||||
}
|
||||
if (e.getChannel.isGlobal && (e.isFromCommand || isdifferentchannel.test(module.chatChannel.get))) {
|
||||
if (MCChatUtils.lastmsgdata == null)
|
||||
|
@ -306,7 +306,7 @@ class MCChatListener(val module: MinecraftChatModule) extends Listener {
|
|||
var dmessage: String = event.getMessage.getContent
|
||||
try {
|
||||
val dsender: DiscordSenderBase = MCChatUtils.getSender(event.getMessage.getChannelId, sender)
|
||||
val user: DiscordPlayer = dsender.getChromaUser
|
||||
val user: DiscordUser = dsender.getChromaUser
|
||||
|
||||
def replaceUserMentions(): Unit = {
|
||||
for (u <- event.getMessage.getUserMentions.asScala) { //TODO: Role mentions
|
||||
|
@ -375,7 +375,7 @@ class MCChatListener(val module: MinecraftChatModule) extends Listener {
|
|||
* @param isPrivate Whether the chat is private
|
||||
* @return Whether the bot should react with a checkmark
|
||||
*/
|
||||
private def handleIngameMessage(event: MessageCreateEvent, dmessage: String, dsender: DiscordSenderBase, user: DiscordPlayer,
|
||||
private def handleIngameMessage(event: MessageCreateEvent, dmessage: String, dsender: DiscordSenderBase, user: DiscordUser,
|
||||
clmd: MCChatCustom.CustomLMD, isPrivate: Boolean): Boolean = {
|
||||
def getAttachmentText = {
|
||||
val att = event.getMessage.getAttachments.asScala
|
||||
|
@ -413,7 +413,7 @@ class MCChatListener(val module: MinecraftChatModule) extends Listener {
|
|||
* @param isPrivate Whether the chat is private
|
||||
* @return
|
||||
*/
|
||||
private def handleIngameCommand(event: MessageCreateEvent, dmessage: String, dsender: DiscordSenderBase, user: DiscordPlayer,
|
||||
private def handleIngameCommand(event: MessageCreateEvent, dmessage: String, dsender: DiscordSenderBase, user: DiscordUser,
|
||||
clmd: MCChatCustom.CustomLMD, isPrivate: Boolean): Unit = {
|
||||
def notWhitelisted(cmd: String) = module.whitelistedCommands.get.stream
|
||||
.noneMatch(s => cmd == s || cmd.startsWith(s + " "))
|
||||
|
|
|
@ -2,7 +2,7 @@ package buttondevteam.discordplugin.mcchat
|
|||
|
||||
import buttondevteam.core.ComponentManager
|
||||
import buttondevteam.discordplugin.mcchat.MCChatUtils.LastMsgData
|
||||
import buttondevteam.discordplugin.mcchat.sender.{DiscordConnectedPlayer, DiscordPlayer, DiscordSenderBase}
|
||||
import buttondevteam.discordplugin.mcchat.sender.{DiscordConnectedPlayer, DiscordUser, DiscordSenderBase}
|
||||
import buttondevteam.discordplugin.DiscordPlugin
|
||||
import buttondevteam.lib.player.TBMCPlayer
|
||||
import discord4j.core.`object`.entity.User
|
||||
|
@ -18,7 +18,7 @@ object MCChatPrivate {
|
|||
*/
|
||||
private[mcchat] var lastmsgPerUser: ListBuffer[LastMsgData] = ListBuffer()
|
||||
|
||||
def privateMCChat(channel: MessageChannel, start: Boolean, user: User, dp: DiscordPlayer): Unit = {
|
||||
def privateMCChat(channel: MessageChannel, start: Boolean, user: User, dp: DiscordUser): Unit = {
|
||||
MCChatUtils.ConnectedSenders synchronized {
|
||||
val mcp = dp.getAs(classOf[TBMCPlayer])
|
||||
if (mcp != null) { // If the accounts aren't connected, can't make a connected sender
|
||||
|
@ -59,7 +59,7 @@ object MCChatPrivate {
|
|||
}
|
||||
}
|
||||
|
||||
def isMinecraftChatEnabled(dp: DiscordPlayer): Boolean = isMinecraftChatEnabled(dp.getDiscordID)
|
||||
def isMinecraftChatEnabled(dp: DiscordUser): Boolean = isMinecraftChatEnabled(dp.getDiscordID)
|
||||
|
||||
def isMinecraftChatEnabled(did: String): Boolean = { // Don't load the player data just for this
|
||||
lastmsgPerUser.exists(_.channel.asInstanceOf[PrivateChannel].getRecipientIds.stream.anyMatch(u => u.asString == did))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package buttondevteam.discordplugin.mcchat
|
||||
|
||||
import buttondevteam.discordplugin.*
|
||||
import buttondevteam.discordplugin.mcchat.sender.{DiscordConnectedPlayer, DiscordPlayer, DiscordPlayerSender}
|
||||
import buttondevteam.discordplugin.mcchat.sender.{DiscordConnectedPlayer, DiscordUser, DiscordPlayerSender}
|
||||
import buttondevteam.lib.TBMCSystemChatEvent
|
||||
import buttondevteam.lib.player.{ChromaGamerBase, TBMCPlayer, TBMCPlayerBase, TBMCYEEHAWEvent}
|
||||
import discord4j.common.util.Snowflake
|
||||
|
@ -32,7 +32,7 @@ class MCListener(val module: MinecraftChatModule) extends Listener {
|
|||
Bukkit.getScheduler.runTaskAsynchronously(DiscordPlugin.plugin, () => {
|
||||
def foo(): Unit = {
|
||||
val p = e.getPlayer
|
||||
val dp = TBMCPlayerBase.getPlayer(p.getUniqueId, classOf[TBMCPlayer]).getAs(classOf[DiscordPlayer])
|
||||
val dp = TBMCPlayerBase.getPlayer(p.getUniqueId, classOf[TBMCPlayer]).getAs(classOf[DiscordUser])
|
||||
if (dp != null)
|
||||
DiscordPlugin.dc.getUserById(Snowflake.of(dp.getDiscordID)).flatMap(user =>
|
||||
user.getPrivateChannel.flatMap(chan => module.chatChannelMono.flatMap(cc => {
|
||||
|
@ -84,7 +84,7 @@ class MCListener(val module: MinecraftChatModule) extends Listener {
|
|||
if (role == null) return ()
|
||||
val source = e.getAffected.getSource
|
||||
if (!source.isPlayer) return ()
|
||||
val p = TBMCPlayerBase.getPlayer(source.getPlayer.getUniqueId, classOf[TBMCPlayer]).getAs(classOf[DiscordPlayer])
|
||||
val p = TBMCPlayerBase.getPlayer(source.getPlayer.getUniqueId, classOf[TBMCPlayer]).getAs(classOf[DiscordUser])
|
||||
if (p == null) return ()
|
||||
DPUtils.ignoreError(DiscordPlugin.dc.getUserById(Snowflake.of(p.getDiscordID))
|
||||
.flatMap(user => user.asMember(DiscordPlugin.mainServer.getId))
|
||||
|
|
|
@ -30,15 +30,15 @@ abstract class DiscordSenderBase protected(var user: User, var channel: MessageC
|
|||
|
||||
def getChannel: MessageChannel = channel
|
||||
|
||||
private var chromaUser: DiscordPlayer = null
|
||||
private var chromaUser: DiscordUser = null
|
||||
|
||||
/**
|
||||
* Loads the user data on first query.
|
||||
*
|
||||
* @return A Chroma user of Discord or a Discord user of Chroma
|
||||
*/
|
||||
def getChromaUser: DiscordPlayer = {
|
||||
if (chromaUser == null) chromaUser = ChromaGamerBase.getUser(user.getId.asString, classOf[DiscordPlayer])
|
||||
def getChromaUser: DiscordUser = {
|
||||
if (chromaUser == null) chromaUser = ChromaGamerBase.getUser(user.getId.asString, classOf[DiscordUser])
|
||||
chromaUser
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import buttondevteam.lib.player.{ChromaGamerBase, UserClass}
|
|||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.`object`.entity.User
|
||||
|
||||
@UserClass(foldername = "discord") class DiscordPlayer() extends ChromaGamerBase {
|
||||
@UserClass(foldername = "discord") class DiscordUser() extends ChromaGamerBase {
|
||||
private var did: String = null
|
||||
private var discordUser: User = null
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package buttondevteam.discordplugin.mccommands
|
||||
|
||||
import buttondevteam.discordplugin.commands.{ConnectCommand, VersionCommand}
|
||||
import buttondevteam.discordplugin.mcchat.sender.{DiscordPlayer, DiscordSenderBase}
|
||||
import buttondevteam.discordplugin.mcchat.sender.{DiscordUser, DiscordSenderBase}
|
||||
import buttondevteam.discordplugin.mcchat.{MCChatUtils, MinecraftChatModule}
|
||||
import buttondevteam.discordplugin.util.DPState
|
||||
import buttondevteam.discordplugin.{DPUtils, DiscordPlugin}
|
||||
|
@ -28,7 +28,7 @@ import java.lang.reflect.Method
|
|||
player.sendMessage("§cYou don't have a pending connection to Discord.")
|
||||
return true
|
||||
}
|
||||
val dp = ChromaGamerBase.getUser(did, classOf[DiscordPlayer])
|
||||
val dp = ChromaGamerBase.getUser(did, classOf[DiscordUser])
|
||||
val mcp = TBMCPlayerBase.getPlayer(player.getUniqueId, classOf[TBMCPlayer])
|
||||
dp.connectWith(mcp)
|
||||
ConnectCommand.WaitingToConnect.remove(player.getName)
|
||||
|
|
Loading…
Reference in a new issue