Update to Scala 3.0.0 and update dependencies
This commit is contained in:
parent
c49fac5ce5
commit
7b27ec0ea3
15 changed files with 276 additions and 273 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -223,3 +223,4 @@ TheButtonAutoFlair/out/artifacts/Autoflair/Autoflair.jar
|
|||
*.xml
|
||||
|
||||
Token.txt
|
||||
.bsp
|
||||
|
|
30
build.sbt
30
build.sbt
|
@ -8,7 +8,7 @@ name := "Chroma-Discord"
|
|||
|
||||
version := "1.1"
|
||||
|
||||
scalaVersion := "2.13.5"
|
||||
scalaVersion := "3.0.0"
|
||||
|
||||
resolvers += "spigot-repo" at "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
|
||||
resolvers += "jitpack.io" at "https://jitpack.io"
|
||||
|
@ -20,35 +20,37 @@ libraryDependencies ++= Seq(
|
|||
"org.spigotmc." % "spigot" % "1.14.4-R0.1-SNAPSHOT" % Provided,
|
||||
"com.destroystokyo.paper" % "paper" % "1.16.3-R0.1-SNAPSHOT" % Provided,
|
||||
|
||||
"com.discord4j" % "discord4j-core" % "3.1.4",
|
||||
"org.slf4j" % "slf4j-jdk14" % "1.7.21",
|
||||
"com.vdurmont" % "emoji-java" % "4.0.0",
|
||||
"org.mockito" % "mockito-core" % "3.5.13",
|
||||
"io.projectreactor" %% "reactor-scala-extensions" % "0.7.0",
|
||||
"com.discord4j" % "discord4j-core" % "3.1.6",
|
||||
"org.slf4j" % "slf4j-jdk14" % "1.7.31",
|
||||
"com.vdurmont" % "emoji-java" % "5.1.1",
|
||||
"org.mockito" % "mockito-core" % "3.11.1",
|
||||
"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,
|
||||
"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"
|
||||
assemblyShadeRules in assembly := Seq(
|
||||
assembly / assemblyJarName := "Chroma-Discord.jar"
|
||||
assembly / assemblyShadeRules := Seq(
|
||||
"io.netty", "com.fasterxml", "org.mockito", "org.slf4j"
|
||||
).map { p =>
|
||||
ShadeRule.rename(s"$p.**" -> "btndvtm.dp.@0").inAll
|
||||
}
|
||||
|
||||
assemblyMergeStrategy in assembly := {
|
||||
assembly / assemblyMergeStrategy := {
|
||||
case PathList("META-INF", "io.netty.versions.properties") => MergeStrategy.concat
|
||||
// https://stackoverflow.com/a/55557287/457612
|
||||
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")
|
||||
saveConfigComments := {
|
||||
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 objRegex = Pattern.compile("object (\\w+)")
|
||||
val subRegex = Pattern.compile("def `?(\\w+)`?")
|
||||
|
@ -81,7 +83,7 @@ saveConfigComments := {
|
|||
else if (clName.contains("Plugin")) "global"
|
||||
else null
|
||||
if (compKey != null)
|
||||
configConfig.set(s"${compKey}.generalDescriptionInsteadOfAConfig", comment.trim)
|
||||
configConfig.set(s"$compKey.generalDescriptionInsteadOfAConfig", comment.trim)
|
||||
}
|
||||
}
|
||||
(clKey, null, false)
|
||||
|
@ -135,4 +137,4 @@ saveConfigComments := {
|
|||
Seq(file("target/configHelp.yml"), file("target/commands.yml"))
|
||||
}
|
||||
|
||||
resourceGenerators in Compile += saveConfigComments
|
||||
Compile / resourceGenerators += saveConfigComments
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
sbt.version=1.4.7
|
||||
scala.version=1.13.1
|
||||
sbt.version=1.5.4
|
||||
scala.version=3.0.0
|
|
@ -4,7 +4,7 @@ import buttondevteam.discordplugin.mcchat.MinecraftChatModule
|
|||
import buttondevteam.discordplugin.playerfaker.{DiscordInventory, VCMDWrapper}
|
||||
import discord4j.core.`object`.entity.User
|
||||
import discord4j.core.`object`.entity.channel.MessageChannel
|
||||
import org.bukkit._
|
||||
import org.bukkit.*
|
||||
import org.bukkit.attribute.{Attribute, AttributeInstance, AttributeModifier}
|
||||
import org.bukkit.entity.{Entity, Player}
|
||||
import org.bukkit.event.player.{AsyncPlayerChatEvent, PlayerTeleportEvent}
|
||||
|
@ -17,7 +17,7 @@ import org.mockito.{MockSettings, Mockito}
|
|||
|
||||
import java.lang.reflect.Modifier
|
||||
import java.util
|
||||
import java.util._
|
||||
import java.util.*
|
||||
|
||||
object 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
|
||||
|
||||
@deprecated override def getMaxHealth = 20
|
||||
@deprecated override def getMaxHealth = 20d
|
||||
|
||||
override def getPlayer: DiscordConnectedPlayer = this
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package buttondevteam.discordplugin
|
|||
|
||||
import buttondevteam.discordplugin.announcer.AnnouncerModule
|
||||
import buttondevteam.discordplugin.broadcaster.GeneralEventBroadcasterModule
|
||||
import buttondevteam.discordplugin.commands._
|
||||
import buttondevteam.discordplugin.commands.*
|
||||
import buttondevteam.discordplugin.exceptions.ExceptionListenerModule
|
||||
import buttondevteam.discordplugin.fun.FunModule
|
||||
import buttondevteam.discordplugin.listeners.{CommonListeners, MCListener}
|
||||
|
@ -11,7 +11,7 @@ import buttondevteam.discordplugin.mccommands.DiscordMCCommand
|
|||
import buttondevteam.discordplugin.role.GameRoleModule
|
||||
import buttondevteam.discordplugin.util.{DPState, Timings}
|
||||
import buttondevteam.lib.TBMCCoreAPI
|
||||
import buttondevteam.lib.architecture._
|
||||
import buttondevteam.lib.architecture.*
|
||||
import buttondevteam.lib.player.ChromaGamerBase
|
||||
import com.google.common.io.Files
|
||||
import discord4j.common.util.Snowflake
|
||||
|
@ -142,13 +142,10 @@ import java.util.Optional
|
|||
|
||||
foo(t)
|
||||
}).subscribe((dc: GatewayDiscordClient) => {
|
||||
def foo(dc: GatewayDiscordClient): Disposable = { //System.out.println("Login successful, got dc: " + dc);
|
||||
DiscordPlugin.dc = dc //Set to gateway client
|
||||
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
|
||||
}
|
||||
|
||||
foo(dc)
|
||||
DiscordPlugin.dc = dc //Set to gateway client
|
||||
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
|
||||
()
|
||||
}) /* All guilds have been received, client is fully connected */
|
||||
} catch {
|
||||
case e: Exception =>
|
||||
|
|
|
@ -18,7 +18,7 @@ class DiscordSender(user: User, channel: MessageChannel, pname: String) extends
|
|||
.map(u => u.getDisplayName)))
|
||||
.getOrElse("Discord user")
|
||||
|
||||
def this(user: User, channel: MessageChannel) {
|
||||
def this(user: User, channel: MessageChannel) = {
|
||||
this(user, channel, null)
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,8 @@ import scala.annotation.tailrec
|
|||
override protected def disable(): Unit = AnnouncerModule.stop = true
|
||||
|
||||
@tailrec
|
||||
private def AnnouncementGetterThreadMethod() {
|
||||
if (AnnouncerModule.stop) return
|
||||
private def AnnouncementGetterThreadMethod(): Unit = {
|
||||
if (AnnouncerModule.stop) return ()
|
||||
if (isEnabled) try { //If not enabled, just wait
|
||||
val body = TBMCCoreAPI.DownloadString(subredditURL.get + "/new/.json?limit=10")
|
||||
val json = new JsonParser().parse(body).getAsJsonObject.get("data").getAsJsonObject.get("children").getAsJsonArray
|
||||
|
|
|
@ -28,7 +28,9 @@ class UserinfoCommand extends ICommand2DC {
|
|||
channel.createMessage("The user cannot be found (by name): " + user).subscribe
|
||||
return true
|
||||
}
|
||||
targets.collectFirst(_.getDiscriminator.equalsIgnoreCase(targettag(1)))
|
||||
targets.collectFirst {
|
||||
case user => user.getDiscriminator.equalsIgnoreCase(targettag(1))
|
||||
}
|
||||
if (target == null) {
|
||||
channel.createMessage("The user cannot be found (by discriminator): " + user + "(Found " + targets.size + " users with the name.)").subscribe
|
||||
return true
|
||||
|
|
|
@ -87,7 +87,7 @@ object FunModule {
|
|||
.filter(_ => lasttime + 10 < TimeUnit.NANOSECONDS.toHours(System.nanoTime)) //This should stay so it checks this last
|
||||
.flatMap(_ => {
|
||||
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"))))
|
||||
})).subscribe
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class MCListener extends Listener {
|
|||
e.addInfo(pr.getStatus.toString)
|
||||
if (pr.getActivity.isPresent) {
|
||||
val activity = pr.getActivity.get
|
||||
e.addInfo(activity.getType + ": " + activity.getName)
|
||||
e.addInfo(s"${activity.getType}: ${activity.getName}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package buttondevteam.discordplugin.mcchat
|
||||
|
||||
import buttondevteam.core.ComponentManager
|
||||
import buttondevteam.discordplugin._
|
||||
import buttondevteam.discordplugin.*
|
||||
import buttondevteam.discordplugin.listeners.CommandListener
|
||||
import buttondevteam.discordplugin.playerfaker.{VanillaCommandListener, VanillaCommandListener14, VanillaCommandListener15}
|
||||
import buttondevteam.lib._
|
||||
import buttondevteam.lib.*
|
||||
import buttondevteam.lib.chat.{ChatMessage, TBMCChatAPI}
|
||||
import buttondevteam.lib.player.TBMCPlayer
|
||||
import com.vdurmont.emoji.EmojiParser
|
||||
|
@ -44,7 +44,7 @@ object MCChatListener {
|
|||
@FunctionalInterface private trait InterruptibleConsumer[T] {
|
||||
@throws[TimeoutException]
|
||||
@throws[InterruptedException]
|
||||
def accept(value: T)
|
||||
def accept(value: T): Unit
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package buttondevteam.discordplugin.mcchat
|
||||
|
||||
import buttondevteam.core.{ComponentManager, MainPlugin, component}
|
||||
import buttondevteam.discordplugin.*
|
||||
import buttondevteam.discordplugin.ChannelconBroadcast.ChannelconBroadcast
|
||||
import buttondevteam.discordplugin._
|
||||
import buttondevteam.discordplugin.broadcaster.GeneralEventBroadcasterModule
|
||||
import buttondevteam.discordplugin.mcchat.MCChatCustom.CustomLMD
|
||||
import buttondevteam.lib.{TBMCCoreAPI, TBMCSystemChatEvent}
|
||||
|
@ -86,7 +86,7 @@ object MCChatUtils {
|
|||
).filter(MCChatUtils.checkEssentials) //If they can see it
|
||||
.filter(_ => C.incrementAndGet > 0) //Always true
|
||||
.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) =>
|
||||
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?
|
||||
MCChatCustom.lastmsgCustom.filter(clmd =>
|
||||
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)
|
||||
()
|
||||
})
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.mockito.invocation.InvocationOnMock
|
|||
|
||||
import java.lang.reflect.Modifier
|
||||
import java.util
|
||||
import java.util._
|
||||
import java.util.*
|
||||
|
||||
object ServerWatcher {
|
||||
|
||||
|
@ -62,7 +62,8 @@ class ServerWatcher {
|
|||
@SuppressWarnings("unchecked") var list = (List<Player>) method.invoke(origServer, invocation.getArguments());
|
||||
playerList = new AppendListView<>(list, fakePlayers);
|
||||
} - Your scientists were so preoccupied with whether or not they could, they didn’t 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) {
|
||||
val uuid = invocation.getArgument(0)
|
||||
val name = invocation.getArgument(1)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package buttondevteam.discordplugin.playerfaker
|
||||
|
||||
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.craftbukkit.v1_12_R1.command.VanillaCommandWrapper
|
||||
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)
|
||||
*/
|
||||
def this(player: T) {
|
||||
def this(player: T) = {
|
||||
this()
|
||||
this.player = player
|
||||
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 bukkitplayer The Bukkit player to send the raw message to
|
||||
*/
|
||||
def this(player: T, bukkitplayer: Player) {
|
||||
def this(player: T, bukkitplayer: Player) = {
|
||||
this()
|
||||
this.player = player
|
||||
this.bukkitplayer = bukkitplayer
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package buttondevteam.discordplugin.playerfaker
|
||||
|
||||
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.command.CommandSender
|
||||
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)
|
||||
*/
|
||||
def this(player: T) {
|
||||
def this(player: T) = {
|
||||
this()
|
||||
this.player = player
|
||||
this.bukkitplayer = null
|
||||
|
@ -63,7 +63,7 @@ class VanillaCommandListener14[T <: DiscordSenderBase with IMCPlayer[T]] extends
|
|||
* @param player The Discord sender player (the wrapper)
|
||||
* @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.player = player
|
||||
this.bukkitplayer = bukkitplayer
|
||||
|
|
Loading…
Reference in a new issue