Update to Scala 3.0.0 and update dependencies

This commit is contained in:
Norbi Peti 2021-07-08 23:04:17 +02:00
parent c49fac5ce5
commit 7b27ec0ea3
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
15 changed files with 276 additions and 273 deletions

1
.gitignore vendored
View file

@ -223,3 +223,4 @@ TheButtonAutoFlair/out/artifacts/Autoflair/Autoflair.jar
*.xml *.xml
Token.txt Token.txt
.bsp

View file

@ -8,7 +8,7 @@ name := "Chroma-Discord"
version := "1.1" version := "1.1"
scalaVersion := "2.13.5" scalaVersion := "3.0.0"
resolvers += "spigot-repo" at "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" resolvers += "spigot-repo" at "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
resolvers += "jitpack.io" at "https://jitpack.io" resolvers += "jitpack.io" at "https://jitpack.io"
@ -20,35 +20,37 @@ libraryDependencies ++= Seq(
"org.spigotmc." % "spigot" % "1.14.4-R0.1-SNAPSHOT" % Provided, "org.spigotmc." % "spigot" % "1.14.4-R0.1-SNAPSHOT" % Provided,
"com.destroystokyo.paper" % "paper" % "1.16.3-R0.1-SNAPSHOT" % Provided, "com.destroystokyo.paper" % "paper" % "1.16.3-R0.1-SNAPSHOT" % Provided,
"com.discord4j" % "discord4j-core" % "3.1.4", "com.discord4j" % "discord4j-core" % "3.1.6",
"org.slf4j" % "slf4j-jdk14" % "1.7.21", "org.slf4j" % "slf4j-jdk14" % "1.7.31",
"com.vdurmont" % "emoji-java" % "4.0.0", "com.vdurmont" % "emoji-java" % "5.1.1",
"org.mockito" % "mockito-core" % "3.5.13", "org.mockito" % "mockito-core" % "3.11.1",
"io.projectreactor" %% "reactor-scala-extensions" % "0.7.0", "io.projectreactor" % "reactor-scala-extensions_2.13" % "0.8.0",
// https://mvnrepository.com/artifact/org.immutables/value
"org.immutables" % "value" % "2.8.8" % "provided",
"com.github.TBMCPlugins.ChromaCore" % "Chroma-Core" % "v1.0.0" % Provided, "com.github.TBMCPlugins.ChromaCore" % "Chroma-Core" % "v1.0.0" % Provided,
"net.ess3" % "EssentialsX" % "2.17.1" % Provided, "net.ess3" % "EssentialsX" % "2.17.1" % Provided,
"com.github.lucko.LuckPerms" % "bukkit" % "master-SNAPSHOT" % Provided, "net.luckperms" % "api" % "5.3" % Provided,
) )
assemblyJarName in assembly := "Chroma-Discord.jar" assembly / assemblyJarName := "Chroma-Discord.jar"
assemblyShadeRules in assembly := Seq( assembly / assemblyShadeRules := Seq(
"io.netty", "com.fasterxml", "org.mockito", "org.slf4j" "io.netty", "com.fasterxml", "org.mockito", "org.slf4j"
).map { p => ).map { p =>
ShadeRule.rename(s"$p.**" -> "btndvtm.dp.@0").inAll ShadeRule.rename(s"$p.**" -> "btndvtm.dp.@0").inAll
} }
assemblyMergeStrategy in assembly := { assembly / assemblyMergeStrategy := {
case PathList("META-INF", "io.netty.versions.properties") => MergeStrategy.concat case PathList("META-INF", "io.netty.versions.properties") => MergeStrategy.concat
// https://stackoverflow.com/a/55557287/457612 // https://stackoverflow.com/a/55557287/457612
case "module-info.class" => MergeStrategy.discard case "module-info.class" => MergeStrategy.discard
case x => (assemblyMergeStrategy in assembly).value(x) case x => (assembly / assemblyMergeStrategy).value(x)
} }
val saveConfigComments = TaskKey[Seq[File]]("saveConfigComments") val saveConfigComments = TaskKey[Seq[File]]("saveConfigComments")
saveConfigComments := { saveConfigComments := {
val sv = (Compile / sources).value val sv = (Compile / sources).value
val cdataRegex = Pattern.compile("(?:def|val|var) (\\w+)(?::[^=]+)? = (?:(?:get(?:I)?Config)|(?:DPUtils.\\w+Data))") //Hack: DPUtils val cdataRegex = Pattern.compile("(?:def|val|var) (\\w+)(?::[^=]+)? = (?:getI?Config|DPUtils.\\w+Data)") //Hack: DPUtils
val clRegex = Pattern.compile("class (\\w+).* extends ((?:\\w|\\d)+)") val clRegex = Pattern.compile("class (\\w+).* extends ((?:\\w|\\d)+)")
val objRegex = Pattern.compile("object (\\w+)") val objRegex = Pattern.compile("object (\\w+)")
val subRegex = Pattern.compile("def `?(\\w+)`?") val subRegex = Pattern.compile("def `?(\\w+)`?")
@ -81,7 +83,7 @@ saveConfigComments := {
else if (clName.contains("Plugin")) "global" else if (clName.contains("Plugin")) "global"
else null else null
if (compKey != null) if (compKey != null)
configConfig.set(s"${compKey}.generalDescriptionInsteadOfAConfig", comment.trim) configConfig.set(s"$compKey.generalDescriptionInsteadOfAConfig", comment.trim)
} }
} }
(clKey, null, false) (clKey, null, false)
@ -135,4 +137,4 @@ saveConfigComments := {
Seq(file("target/configHelp.yml"), file("target/commands.yml")) Seq(file("target/configHelp.yml"), file("target/commands.yml"))
} }
resourceGenerators in Compile += saveConfigComments Compile / resourceGenerators += saveConfigComments

View file

@ -1,2 +1,2 @@
sbt.version=1.4.7 sbt.version=1.5.4
scala.version=1.13.1 scala.version=3.0.0

View file

@ -4,7 +4,7 @@ import buttondevteam.discordplugin.mcchat.MinecraftChatModule
import buttondevteam.discordplugin.playerfaker.{DiscordInventory, VCMDWrapper} import buttondevteam.discordplugin.playerfaker.{DiscordInventory, VCMDWrapper}
import discord4j.core.`object`.entity.User import discord4j.core.`object`.entity.User
import discord4j.core.`object`.entity.channel.MessageChannel import discord4j.core.`object`.entity.channel.MessageChannel
import org.bukkit._ import org.bukkit.*
import org.bukkit.attribute.{Attribute, AttributeInstance, AttributeModifier} import org.bukkit.attribute.{Attribute, AttributeInstance, AttributeModifier}
import org.bukkit.entity.{Entity, Player} import org.bukkit.entity.{Entity, Player}
import org.bukkit.event.player.{AsyncPlayerChatEvent, PlayerTeleportEvent} import org.bukkit.event.player.{AsyncPlayerChatEvent, PlayerTeleportEvent}
@ -17,7 +17,7 @@ import org.mockito.{MockSettings, Mockito}
import java.lang.reflect.Modifier import java.lang.reflect.Modifier
import java.util import java.util
import java.util._ import java.util.*
object DiscordConnectedPlayer { object DiscordConnectedPlayer {
def create(user: User, channel: MessageChannel, uuid: UUID, mcname: String, module: MinecraftChatModule): DiscordConnectedPlayer = def create(user: User, channel: MessageChannel, uuid: UUID, mcname: String, module: MinecraftChatModule): DiscordConnectedPlayer =
@ -170,7 +170,7 @@ abstract class DiscordConnectedPlayer(user: User, channel: MessageChannel, val u
override def getEyeLocation: Location = getLocation override def getEyeLocation: Location = getLocation
@deprecated override def getMaxHealth = 20 @deprecated override def getMaxHealth = 20d
override def getPlayer: DiscordConnectedPlayer = this override def getPlayer: DiscordConnectedPlayer = this

View file

@ -2,7 +2,7 @@ package buttondevteam.discordplugin
import buttondevteam.discordplugin.announcer.AnnouncerModule import buttondevteam.discordplugin.announcer.AnnouncerModule
import buttondevteam.discordplugin.broadcaster.GeneralEventBroadcasterModule import buttondevteam.discordplugin.broadcaster.GeneralEventBroadcasterModule
import buttondevteam.discordplugin.commands._ import buttondevteam.discordplugin.commands.*
import buttondevteam.discordplugin.exceptions.ExceptionListenerModule 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}
@ -11,7 +11,7 @@ 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}
import buttondevteam.lib.TBMCCoreAPI import buttondevteam.lib.TBMCCoreAPI
import buttondevteam.lib.architecture._ import buttondevteam.lib.architecture.*
import buttondevteam.lib.player.ChromaGamerBase import buttondevteam.lib.player.ChromaGamerBase
import com.google.common.io.Files import com.google.common.io.Files
import discord4j.common.util.Snowflake import discord4j.common.util.Snowflake
@ -142,13 +142,10 @@ import java.util.Optional
foo(t) foo(t)
}).subscribe((dc: GatewayDiscordClient) => { }).subscribe((dc: GatewayDiscordClient) => {
def foo(dc: GatewayDiscordClient): Disposable = { //System.out.println("Login successful, got dc: " + dc); DiscordPlugin.dc = dc //Set to gateway client
DiscordPlugin.dc = dc //Set to gateway client dc.on(classOf[ReadyEvent]).map(_.getGuilds.size).flatMap(dc.on(classOf[GuildCreateEvent]).take(_).collectList)
dc.on(classOf[ReadyEvent]).map(_.getGuilds.size).flatMap(dc.on(classOf[GuildCreateEvent]).take(_).collectList) .doOnError(_ => stopStarting()).subscribe(this.handleReady _) // Take all received GuildCreateEvents and make it a List
.doOnError(_ => stopStarting()).subscribe(this.handleReady _) // Take all received GuildCreateEvents and make it a List ()
}
foo(dc)
}) /* All guilds have been received, client is fully connected */ }) /* All guilds have been received, client is fully connected */
} catch { } catch {
case e: Exception => case e: Exception =>

View file

@ -18,7 +18,7 @@ class DiscordSender(user: User, channel: MessageChannel, pname: String) extends
.map(u => u.getDisplayName))) .map(u => u.getDisplayName)))
.getOrElse("Discord user") .getOrElse("Discord user")
def this(user: User, channel: MessageChannel) { def this(user: User, channel: MessageChannel) = {
this(user, channel, null) this(user, channel, null)
} }

View file

@ -50,8 +50,8 @@ import scala.annotation.tailrec
override protected def disable(): Unit = AnnouncerModule.stop = true override protected def disable(): Unit = AnnouncerModule.stop = true
@tailrec @tailrec
private def AnnouncementGetterThreadMethod() { private def AnnouncementGetterThreadMethod(): Unit = {
if (AnnouncerModule.stop) return if (AnnouncerModule.stop) return ()
if (isEnabled) try { //If not enabled, just wait if (isEnabled) try { //If not enabled, just wait
val body = TBMCCoreAPI.DownloadString(subredditURL.get + "/new/.json?limit=10") val body = TBMCCoreAPI.DownloadString(subredditURL.get + "/new/.json?limit=10")
val json = new JsonParser().parse(body).getAsJsonObject.get("data").getAsJsonObject.get("children").getAsJsonArray val json = new JsonParser().parse(body).getAsJsonObject.get("data").getAsJsonObject.get("children").getAsJsonArray

View file

@ -28,7 +28,9 @@ class UserinfoCommand extends ICommand2DC {
channel.createMessage("The user cannot be found (by name): " + user).subscribe channel.createMessage("The user cannot be found (by name): " + user).subscribe
return true return true
} }
targets.collectFirst(_.getDiscriminator.equalsIgnoreCase(targettag(1))) targets.collectFirst {
case user => user.getDiscriminator.equalsIgnoreCase(targettag(1))
}
if (target == null) { if (target == null) {
channel.createMessage("The user cannot be found (by discriminator): " + user + "(Found " + targets.size + " users with the name.)").subscribe channel.createMessage("The user cannot be found (by discriminator): " + user + "(Found " + targets.size + " users with the name.)").subscribe
return true return true

View file

@ -87,7 +87,7 @@ object FunModule {
.filter(_ => lasttime + 10 < TimeUnit.NANOSECONDS.toHours(System.nanoTime)) //This should stay so it checks this last .filter(_ => lasttime + 10 < TimeUnit.NANOSECONDS.toHours(System.nanoTime)) //This should stay so it checks this last
.flatMap(_ => { .flatMap(_ => {
lasttime = TimeUnit.NANOSECONDS.toHours(System.nanoTime) lasttime = TimeUnit.NANOSECONDS.toHours(System.nanoTime)
SMono(channel.createMessage((mcs: MessageCreateSpec) => mcs.setContent("Full house!") SMono(channel.createMessage(_.setContent("Full house!")
.setEmbed((ecs: EmbedCreateSpec) => ecs.setImage("https://cdn.discordapp.com/attachments/249295547263877121/249687682618359808/poker-hand-full-house-aces-kings-playing-cards-15553791.png")))) .setEmbed((ecs: EmbedCreateSpec) => ecs.setImage("https://cdn.discordapp.com/attachments/249295547263877121/249687682618359808/poker-hand-full-house-aces-kings-playing-cards-15553791.png"))))
})).subscribe })).subscribe
} }

View file

@ -37,7 +37,7 @@ class MCListener extends Listener {
e.addInfo(pr.getStatus.toString) e.addInfo(pr.getStatus.toString)
if (pr.getActivity.isPresent) { if (pr.getActivity.isPresent) {
val activity = pr.getActivity.get val activity = pr.getActivity.get
e.addInfo(activity.getType + ": " + activity.getName) e.addInfo(s"${activity.getType}: ${activity.getName}")
} }
} }

View file

@ -1,10 +1,10 @@
package buttondevteam.discordplugin.mcchat package buttondevteam.discordplugin.mcchat
import buttondevteam.core.ComponentManager import buttondevteam.core.ComponentManager
import buttondevteam.discordplugin._ import buttondevteam.discordplugin.*
import buttondevteam.discordplugin.listeners.CommandListener import buttondevteam.discordplugin.listeners.CommandListener
import buttondevteam.discordplugin.playerfaker.{VanillaCommandListener, VanillaCommandListener14, VanillaCommandListener15} import buttondevteam.discordplugin.playerfaker.{VanillaCommandListener, VanillaCommandListener14, VanillaCommandListener15}
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
import com.vdurmont.emoji.EmojiParser import com.vdurmont.emoji.EmojiParser
@ -44,7 +44,7 @@ object MCChatListener {
@FunctionalInterface private trait InterruptibleConsumer[T] { @FunctionalInterface private trait InterruptibleConsumer[T] {
@throws[TimeoutException] @throws[TimeoutException]
@throws[InterruptedException] @throws[InterruptedException]
def accept(value: T) def accept(value: T): Unit
} }
} }

View file

@ -1,8 +1,8 @@
package buttondevteam.discordplugin.mcchat package buttondevteam.discordplugin.mcchat
import buttondevteam.core.{ComponentManager, MainPlugin, component} import buttondevteam.core.{ComponentManager, MainPlugin, component}
import buttondevteam.discordplugin.*
import buttondevteam.discordplugin.ChannelconBroadcast.ChannelconBroadcast import buttondevteam.discordplugin.ChannelconBroadcast.ChannelconBroadcast
import buttondevteam.discordplugin._
import buttondevteam.discordplugin.broadcaster.GeneralEventBroadcasterModule import buttondevteam.discordplugin.broadcaster.GeneralEventBroadcasterModule
import buttondevteam.discordplugin.mcchat.MCChatCustom.CustomLMD import buttondevteam.discordplugin.mcchat.MCChatCustom.CustomLMD
import buttondevteam.lib.{TBMCCoreAPI, TBMCSystemChatEvent} import buttondevteam.lib.{TBMCCoreAPI, TBMCSystemChatEvent}
@ -86,7 +86,7 @@ object MCChatUtils {
).filter(MCChatUtils.checkEssentials) //If they can see it ).filter(MCChatUtils.checkEssentials) //If they can see it
.filter(_ => C.incrementAndGet > 0) //Always true .filter(_ => C.incrementAndGet > 0) //Always true
.map((p) => DPUtils.sanitizeString(p.getDisplayName)).collect(Collectors.joining(", ")) .map((p) => DPUtils.sanitizeString(p.getDisplayName)).collect(Collectors.joining(", "))
s(0) = C + " player" + (if (C.get != 1) "s" else "") + " online" s(0) = s"$C player${if (C.get != 1) "s" else ""} online"
lmd.channel.asInstanceOf[TextChannel].edit((tce: TextChannelEditSpec) => lmd.channel.asInstanceOf[TextChannel].edit((tce: TextChannelEditSpec) =>
tce.setTopic(String.join("\n----\n", s: _*)).setReason("Player list update")).subscribe //Don't wait tce.setTopic(String.join("\n----\n", s: _*)).setReason("Player list update")).subscribe //Don't wait
} }
@ -192,7 +192,7 @@ object MCChatUtils {
list.append(action(SMono.just(data.channel))) //TODO: Only store ID? list.append(action(SMono.just(data.channel))) //TODO: Only store ID?
MCChatCustom.lastmsgCustom.filter(clmd => MCChatCustom.lastmsgCustom.filter(clmd =>
clmd.brtoggles.contains(event.getTarget) && event.shouldSendTo(clmd.dcp)) clmd.brtoggles.contains(event.getTarget) && event.shouldSendTo(clmd.dcp))
.map(clmd => action(SMono.just(clmd.channel))).forEach(elem => { .map(clmd => action(SMono.just(clmd.channel))).foreach(elem => {
list.append(elem) list.append(elem)
() ()
}) })

View file

@ -12,7 +12,7 @@ import org.mockito.invocation.InvocationOnMock
import java.lang.reflect.Modifier import java.lang.reflect.Modifier
import java.util import java.util
import java.util._ import java.util.*
object ServerWatcher { object ServerWatcher {
@ -62,7 +62,8 @@ class ServerWatcher {
@SuppressWarnings("unchecked") var list = (List<Player>) method.invoke(origServer, invocation.getArguments()); @SuppressWarnings("unchecked") var list = (List<Player>) method.invoke(origServer, invocation.getArguments());
playerList = new AppendListView<>(list, fakePlayers); playerList = new AppendListView<>(list, fakePlayers);
} - Your scientists were so preoccupied with whether or not they could, they didnt stop to think if they should. } - Your scientists were so preoccupied with whether or not they could, they didnt stop to think if they should.
return playerList;*/ case "createProfile" => //Paper's method, casts the player to a CraftPlayer return playerList;*/
case "createProfile" => //Paper's method, casts the player to a CraftPlayer
if (pc == 2) { if (pc == 2) {
val uuid = invocation.getArgument(0) val uuid = invocation.getArgument(0)
val name = invocation.getArgument(1) val name = invocation.getArgument(1)

View file

@ -1,7 +1,7 @@
package buttondevteam.discordplugin.playerfaker package buttondevteam.discordplugin.playerfaker
import buttondevteam.discordplugin.{DiscordSenderBase, IMCPlayer} import buttondevteam.discordplugin.{DiscordSenderBase, IMCPlayer}
import net.minecraft.server.v1_12_R1._ import net.minecraft.server.v1_12_R1.*
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.craftbukkit.v1_12_R1.command.VanillaCommandWrapper import org.bukkit.craftbukkit.v1_12_R1.command.VanillaCommandWrapper
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer
@ -47,7 +47,7 @@ class VanillaCommandListener[T <: DiscordSenderBase with IMCPlayer[T]] extends I
* *
* @param player The Discord sender player (the wrapper) * @param player The Discord sender player (the wrapper)
*/ */
def this(player: T) { def this(player: T) = {
this() this()
this.player = player this.player = player
this.bukkitplayer = null this.bukkitplayer = null
@ -59,7 +59,7 @@ class VanillaCommandListener[T <: DiscordSenderBase with IMCPlayer[T]] extends I
* @param player The Discord sender player (the wrapper) * @param player The Discord sender player (the wrapper)
* @param bukkitplayer The Bukkit player to send the raw message to * @param bukkitplayer The Bukkit player to send the raw message to
*/ */
def this(player: T, bukkitplayer: Player) { def this(player: T, bukkitplayer: Player) = {
this() this()
this.player = player this.player = player
this.bukkitplayer = bukkitplayer this.bukkitplayer = bukkitplayer

View file

@ -1,7 +1,7 @@
package buttondevteam.discordplugin.playerfaker package buttondevteam.discordplugin.playerfaker
import buttondevteam.discordplugin.{DiscordSenderBase, IMCPlayer} import buttondevteam.discordplugin.{DiscordSenderBase, IMCPlayer}
import net.minecraft.server.v1_14_R1._ import net.minecraft.server.v1_14_R1.*
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.command.CommandSender import org.bukkit.command.CommandSender
import org.bukkit.craftbukkit.v1_14_R1.command.{ProxiedNativeCommandSender, VanillaCommandWrapper} import org.bukkit.craftbukkit.v1_14_R1.command.{ProxiedNativeCommandSender, VanillaCommandWrapper}
@ -51,7 +51,7 @@ class VanillaCommandListener14[T <: DiscordSenderBase with IMCPlayer[T]] extends
* *
* @param player The Discord sender player (the wrapper) * @param player The Discord sender player (the wrapper)
*/ */
def this(player: T) { def this(player: T) = {
this() this()
this.player = player this.player = player
this.bukkitplayer = null this.bukkitplayer = null
@ -63,7 +63,7 @@ class VanillaCommandListener14[T <: DiscordSenderBase with IMCPlayer[T]] extends
* @param player The Discord sender player (the wrapper) * @param player The Discord sender player (the wrapper)
* @param bukkitplayer The Bukkit player to send the raw message to * @param bukkitplayer The Bukkit player to send the raw message to
*/ */
def this(player: T, bukkitplayer: Player) { def this(player: T, bukkitplayer: Player) = {
this() this()
this.player = player this.player = player
this.bukkitplayer = bukkitplayer this.bukkitplayer = bukkitplayer