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