Fix subcommand detection, fix returns
This commit is contained in:
parent
7b27ec0ea3
commit
263c652d68
3 changed files with 25 additions and 19 deletions
|
@ -117,8 +117,9 @@ saveConfigComments := {
|
||||||
val subMatcher = subRegex.matcher(line)
|
val subMatcher = subRegex.matcher(line)
|
||||||
val subParamMatcher = subParamRegex.matcher(line)
|
val subParamMatcher = subParamRegex.matcher(line)
|
||||||
val sub = line.contains("@Subcommand") || line.contains("@Command2.Subcommand")
|
val sub = line.contains("@Subcommand") || line.contains("@Command2.Subcommand")
|
||||||
if (subCommand || sub) //This line or the previous one had the annotation
|
if (sub) subCommand = true
|
||||||
if (subMatcher.find()) {
|
else if (line.contains("}")) subCommand = false
|
||||||
|
if (subCommand && subMatcher.find()) {
|
||||||
/*val groups = (2 to subMatcher.groupCount()).map(subMatcher.group)
|
/*val groups = (2 to subMatcher.groupCount()).map(subMatcher.group)
|
||||||
val pairs = for (i <- groups.indices by 2) yield (groups(i), groups(i + 1))*/
|
val pairs = for (i <- groups.indices by 2) yield (groups(i), groups(i + 1))*/
|
||||||
val mname = subMatcher.group(1)
|
val mname = subMatcher.group(1)
|
||||||
|
@ -127,8 +128,8 @@ saveConfigComments := {
|
||||||
val section = commandConfig.createSection(s"$pkg.$clName.$mname")
|
val section = commandConfig.createSection(s"$pkg.$clName.$mname")
|
||||||
section.set("method", s"$mname()")
|
section.set("method", s"$mname()")
|
||||||
section.set("params", params.mkString(" "))
|
section.set("params", params.mkString(" "))
|
||||||
|
subCommand = false
|
||||||
}
|
}
|
||||||
subCommand = sub
|
|
||||||
}
|
}
|
||||||
configConfig.save("target/configHelp.yml")
|
configConfig.save("target/configHelp.yml")
|
||||||
commandConfig.save("target/commands.yml")
|
commandConfig.save("target/commands.yml")
|
||||||
|
|
|
@ -49,12 +49,13 @@ object MCChatUtils {
|
||||||
|
|
||||||
def updatePlayerList(): Unit = {
|
def updatePlayerList(): Unit = {
|
||||||
val mod = getModule
|
val mod = getModule
|
||||||
if (mod == null || !mod.showPlayerListOnDC.get) return
|
if (mod == null || !mod.showPlayerListOnDC.get) return ()
|
||||||
if (lastmsgdata != null) updatePL(lastmsgdata)
|
if (lastmsgdata != null) updatePL(lastmsgdata)
|
||||||
MCChatCustom.lastmsgCustom.foreach(MCChatUtils.updatePL)
|
MCChatCustom.lastmsgCustom.foreach(MCChatUtils.updatePL)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def notEnabled = (module == null || !module.disabling) && getModule == null //Allow using things while disabling the module
|
private def notEnabled = (module == null || !module.disabling) && getModule == null //Allow using things while disabling the module
|
||||||
|
|
||||||
private def getModule = {
|
private def getModule = {
|
||||||
if (module == null || !module.isEnabled) module = ComponentManager.getIfEnabled(classOf[MinecraftChatModule])
|
if (module == null || !module.isEnabled) module = ComponentManager.getIfEnabled(classOf[MinecraftChatModule])
|
||||||
//If disabled, it will try to get it again because another instance may be enabled - useful for /discord restart
|
//If disabled, it will try to get it again because another instance may be enabled - useful for /discord restart
|
||||||
|
@ -218,7 +219,7 @@ object MCChatUtils {
|
||||||
* @param channel The channel to reset in - the process is slightly different for the public, private and custom chats
|
* @param channel The channel to reset in - the process is slightly different for the public, private and custom chats
|
||||||
*/
|
*/
|
||||||
def resetLastMessage(channel: Channel): Unit = {
|
def resetLastMessage(channel: Channel): Unit = {
|
||||||
if (notEnabled) return
|
if (notEnabled) return ()
|
||||||
if (channel.getId.asLong == module.chatChannel.get.asLong) {
|
if (channel.getId.asLong == module.chatChannel.get.asLong) {
|
||||||
if (lastmsgdata == null) lastmsgdata = new MCChatUtils.LastMsgData(module.chatChannelMono.block(), null)
|
if (lastmsgdata == null) lastmsgdata = new MCChatUtils.LastMsgData(module.chatChannelMono.block(), null)
|
||||||
else lastmsgdata.message = null
|
else lastmsgdata.message = null
|
||||||
|
|
|
@ -101,7 +101,7 @@ class MinecraftChatModule extends Component[DiscordPlugin] {
|
||||||
final private val channelconCommand = new ChannelconCommand(this)
|
final private val channelconCommand = new ChannelconCommand(this)
|
||||||
|
|
||||||
override protected def enable(): Unit = {
|
override protected def enable(): Unit = {
|
||||||
if (DPUtils.disableIfConfigErrorRes(this, chatChannel, chatChannelMono)) return
|
if (DPUtils.disableIfConfigErrorRes(this, chatChannel, chatChannelMono)) return ()
|
||||||
listener = new MCChatListener(this)
|
listener = new MCChatListener(this)
|
||||||
TBMCCoreAPI.RegisterEventsForExceptions(listener, getPlugin)
|
TBMCCoreAPI.RegisterEventsForExceptions(listener, getPlugin)
|
||||||
TBMCCoreAPI.RegisterEventsForExceptions(new MCListener(this), getPlugin) //These get undone if restarting/resetting - it will ignore events if disabled
|
TBMCCoreAPI.RegisterEventsForExceptions(new MCListener(this), getPlugin) //These get undone if restarting/resetting - it will ignore events if disabled
|
||||||
|
@ -219,10 +219,14 @@ class MinecraftChatModule extends Component[DiscordPlugin] {
|
||||||
* It will block to make sure all messages are sent
|
* It will block to make sure all messages are sent
|
||||||
*/
|
*/
|
||||||
private def sendStateMessage(color: Color, message: String) =
|
private def sendStateMessage(color: Color, message: String) =
|
||||||
MCChatUtils.forCustomAndAllMCChat(_.flatMap(_.createEmbed(spec => spec.setColor(color).setTitle(message)).^^()),
|
MCChatUtils.forCustomAndAllMCChat(_.flatMap(
|
||||||
ChannelconBroadcast.RESTART, hookmsg = false).block()
|
_.createEmbed(_.setColor(color).setTitle(message)).^^()
|
||||||
|
.onErrorResume(_ => SMono.empty)
|
||||||
|
), ChannelconBroadcast.RESTART, hookmsg = false).block()
|
||||||
|
|
||||||
private def sendStateMessage(color: Color, message: String, extra: String) =
|
private def sendStateMessage(color: Color, message: String, extra: String) =
|
||||||
MCChatUtils.forCustomAndAllMCChat(_.flatMap(_.createEmbed(_.setColor(color).setTitle(message).setDescription(extra).^^()).^^()
|
MCChatUtils.forCustomAndAllMCChat(_.flatMap(
|
||||||
.onErrorResume(_ => SMono.empty)), ChannelconBroadcast.RESTART, hookmsg = false).block()
|
_.createEmbed(_.setColor(color).setTitle(message).setDescription(extra).^^()).^^()
|
||||||
|
.onErrorResume(_ => SMono.empty)
|
||||||
|
), ChannelconBroadcast.RESTART, hookmsg = false).block()
|
||||||
}
|
}
|
Loading…
Reference in a new issue