Convert to SBT project (manually), including shading

This commit is contained in:
Norbi Peti 2021-04-04 00:32:27 +02:00
parent 1b1a592a1e
commit efa1dcfc8f
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
15 changed files with 102 additions and 271 deletions

74
build.sbt Normal file
View file

@ -0,0 +1,74 @@
name := "Chroma-Discord"
version := "0.1"
scalaVersion := "2.13.5"
resolvers += "spigot-repo" at "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
resolvers += "jitpack.io" at "https://jitpack.io"
resolvers += Resolver.mavenLocal
libraryDependencies ++= Seq(
"org.spigotmc" % "spigot-api" % "1.12.2-R0.1-SNAPSHOT" % Provided,
"org.spigotmc" % "spigot" % "1.12.2-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.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.github.TBMCPlugins.ChromaCore" % "Chroma-Core" % "v1.0.0" % Provided,
"net.ess3" % "EssentialsX" % "2.17.1" % Provided,
"com.github.lucko.LuckPerms" % "bukkit" % "master-SNAPSHOT" % Provided,
)
/*val myAssemblySettings = inTask(assembly)(
Seq(
assemblyShadeRules := libraryDependencies.value.filter(!_.configurations.exists(_ contains "provided"))
.map { _.organization }
.map { p =>
ShadeRule.rename(s"$p.**" -> "btndvtm.dp.@0").inAll
},
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.value(x)
},
/*shadeResourceTransformers ++= Seq(
Rename(
"libnetty_tcnative_linux_x86_64.so" -> "libcom_couchbase_client_core_deps_netty_tcnative_linux_x86_64.so",
"libnetty_tcnative_osx_x86_64.jnilib" -> "libcom_couchbase_client_core_deps_netty_tcnative_osx_x86_64.jnilib",
"netty_tcnative_windows_x86_64.dll" -> "com_couchbase_client_core_deps_netty_tcnative_windows_x86_64.dll"
).inDir("META-INF/native"),
Discard(
"com.fasterxml.jackson.core.JsonFactory",
"com.fasterxml.jackson.core.ObjectCodec",
"com.fasterxml.jackson.databind.Module"
).inDir("META-INF/services")
)*/
)
)*/
assemblyJarName in assembly := "Chroma-Discord.jar"
//assemblyShadeRules in assembly := libraryDependencies.value.filter(!_.configurations.exists(_ contains "provided"))
assemblyShadeRules in assembly := Seq(
"io.netty", "com.fasterxml", "org.mockito", "org.slf4j"
).map { p =>
ShadeRule.rename(s"$p.**" -> "btndvtm.dp.@0").inAll
}
//logLevel in assembly := Level.Debug
assemblyMergeStrategy in assembly := {
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)
}
//lazy val `Chroma-Discord` = project.settings(myAssemblySettings)

254
pom.xml
View file

@ -1,254 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
<artifactId>CorePOM</artifactId>
<version>master-SNAPSHOT</version>
</parent>
<groupId>com.github.TBMCPlugins</groupId>
<artifactId>Chroma-Discord</artifactId>
<version>v${noprefix.version}-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Chroma-Discord</name>
<url>http://maven.apache.org</url>
<build>
<!-- <sourceDirectory>target/generated-sources/delombok</sourceDirectory>
<testSourceDirectory>target/generated-test-sources/delombok</testSourceDirectory> -->
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<finalName>Chroma-Discord</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<!-- <includes>
<include>com.discord4j:discord4j*</include>
<include>com.vdurmont:emoji-java</include>
</includes> --> <!-- http://stackoverflow.com/questions/28458058/maven-shade-plugin-exclude-a-dependency-and-all-its-transitive-dependencies -->
</artifactSet>
<!-- <minimizeJar>true</minimizeJar> Tried using filters but we need pretty much all of that 12 MB -->
<relocations>
<relocation>
<pattern>io.netty</pattern>
<shadedPattern>btndvtm.dp.io.netty</shadedPattern>
<excludes>
</excludes>
</relocation>
<relocation>
<pattern>com.fasterxml</pattern>
<shadedPattern>btndvtm.dp.com.fasterxml</shadedPattern>
</relocation>
<relocation>
<pattern>org.mockito</pattern>
<shadedPattern>btndvtm.dp.org.mockito</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>btndvtm.dp.org.slf4j</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<useSystemClassLoader>false
</useSystemClassLoader> <!-- https://stackoverflow.com/a/53012553/2703239 -->
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>4.4.0</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- <sendJavaToScalac>false</sendJavaToScalac> -->
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<noprefix.version>1.0.0</noprefix.version>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository> <!-- This repo fixes issues with transitive dependencies -->
<id>jcenter</id>
<url>http://jcenter.bintray.com</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<!-- <repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository> -->
<repository>
<id>Essentials</id>
<url>https://ci.ender.zone/plugin/repository/everything/</url>
</repository>
<repository>
<id>projectlombok.org</id>
<url>http://projectlombok.org/mavenrepo</url>
</repository>
<!-- <repository>
<id>pex-repo</id>
<url>http://pex-repo.aoeu.xyz</url>
</repository> -->
<!-- <repository>
<id>Reactor-Tools</id>
<url>https://repo.spring.io/milestone</url>
</repository> -->
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>ossSonatypeSnapshot</id>
<name>OSS Sonatype Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc.</groupId>
<artifactId>spigot</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency> <!-- From patched_1.16.3.jar -->
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper</artifactId>
<version>1.16.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.discord4j/Discord4J -->
<dependency>
<groupId>com.discord4j</groupId>
<artifactId>discord4j-core</artifactId>
<version>3.1.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-jdk14 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
<artifactId>Chroma-Core</artifactId>
<version>v1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>EssentialsX</artifactId>
<version>2.17.1</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>
<groupId>ru.tehkode</groupId>
<artifactId>PermissionsEx</artifactId>
<version>1.23.1</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
</exclusions>
</dependency> -->
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>emoji-java</artifactId>
<version>4.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.projectreactor.tools/blockhound -->
<!-- <dependency>
<groupId>io.projectreactor.tools</groupId>
<artifactId>blockhound</artifactId>
<version>1.0.0.M3</version>
</dependency> -->
<dependency>
<groupId>com.github.lucko.LuckPerms</groupId>
<artifactId>bukkit</artifactId>
<version>master-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.5.13</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.13.1</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-scala-extensions_2.13</artifactId>
<version>0.7.0</version>
</dependency>
</dependencies>
</project>

2
project/build.properties Normal file
View file

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

2
project/plugins.sbt Normal file
View file

@ -0,0 +1,2 @@
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0")
//addSbtPlugin("com.sandinh" % "sbt-shade" % "0.1.2")

View file

@ -18,7 +18,7 @@ object ChromaBot {
/** /**
* Send a message to the chat channels and private chats. * Send a message to the chat channels and private chats.
* *
* @param message The message to send, duh (use {@link MessageChannel# createMessage ( String )}) * @param message The message to send, duh (use [[MessageChannel.createMessage]])
*/ */
def sendMessage(message: SMono[MessageChannel] => SMono[Message]): Unit = def sendMessage(message: SMono[MessageChannel] => SMono[Message]): Unit =
MCChatUtils.forPublicPrivateChat(message).subscribe MCChatUtils.forPublicPrivateChat(message).subscribe

View file

@ -82,7 +82,7 @@ object DPUtils {
roleData(config, key, defName, SMono.just(DiscordPlugin.mainServer)) roleData(config, key, defName, SMono.just(DiscordPlugin.mainServer))
/** /**
* Needs to be a {@link ConfigData} for checking if it's set * Needs to be a [[ConfigData]] for checking if it's set
*/ */
def roleData(config: IHaveConfig, key: String, defName: String, guild: SMono[Guild]): ReadOnlyConfigData[SMono[Role]] = config.getReadOnlyDataPrimDef(key, defName, (name: Any) => { def roleData(config: IHaveConfig, key: String, defName: String, guild: SMono[Guild]): ReadOnlyConfigData[SMono[Role]] = config.getReadOnlyDataPrimDef(key, defName, (name: Any) => {
def foo(name: Any): SMono[Role] = { def foo(name: Any): SMono[Role] = {

View file

@ -49,7 +49,7 @@ object DiscordConnectedPlayer {
} }
/** /**
* @constructor The parameters must match with {@link #create ( User, MessageChannel, UUID, String, MinecraftChatModule)} * @constructor The parameters must match with [[DiscordConnectedPlayer.create]]
* @param user May be null. * @param user May be null.
* @param channel May not be null. * @param channel May not be null.
* @param uniqueId The UUID of the player. * @param uniqueId The UUID of the player.

View file

@ -14,7 +14,7 @@ import buttondevteam.lib.player.{ChromaGamerBase, UserClass}
/** /**
* Returns true if player has the private Minecraft chat enabled. For setting the value, see * Returns true if player has the private Minecraft chat enabled. For setting the value, see
* {@link MCChatPrivate# privateMCChat ( MessageChannel, boolean, User, DiscordPlayer)} * [[MCChatPrivate.privateMCChat]]
*/ */
def isMinecraftChatEnabled: Boolean = MCChatPrivate.isMinecraftChatEnabled(this) def isMinecraftChatEnabled: Boolean = MCChatPrivate.isMinecraftChatEnabled(this)
} }

View file

@ -22,6 +22,7 @@ import discord4j.core.event.domain.guild.GuildCreateEvent
import discord4j.core.event.domain.lifecycle.ReadyEvent import discord4j.core.event.domain.lifecycle.ReadyEvent
import discord4j.core.{DiscordClientBuilder, GatewayDiscordClient} import discord4j.core.{DiscordClientBuilder, GatewayDiscordClient}
import discord4j.gateway.ShardInfo import discord4j.gateway.ShardInfo
import discord4j.rest.interaction.Interactions
import discord4j.store.jdk.JdkStoreService import discord4j.store.jdk.JdkStoreService
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.core.Logger import org.apache.logging.log4j.core.Logger
@ -216,6 +217,8 @@ import java.util.Optional
blw.start() blw.start()
LogManager.getRootLogger.asInstanceOf[Logger].addAppender(blw) LogManager.getRootLogger.asInstanceOf[Logger].addAppender(blw)
logWatcher = blw logWatcher = blw
Interactions.create().onCommand("teszt", Interactions.createHandler()
.guild(gi => gi.acknowledge().withFollowup(_.createFollowupMessage("Teszt"))).build());
if (!TBMCCoreAPI.IsTestServer) DiscordPlugin.dc.updatePresence(Presence.online(Activity.playing("Minecraft"))).subscribe if (!TBMCCoreAPI.IsTestServer) DiscordPlugin.dc.updatePresence(Presence.online(Activity.playing("Minecraft"))).subscribe
else DiscordPlugin.dc.updatePresence(Presence.online(Activity.playing("testing"))).subscribe else DiscordPlugin.dc.updatePresence(Presence.online(Activity.playing("testing"))).subscribe
getLogger.info("Loaded!") getLogger.info("Loaded!")

View file

@ -57,4 +57,5 @@ class DiscordSender(user: User, channel: MessageChannel, pname: String) extends
override def getName: String = name override def getName: String = name
//override def spigot(): CommandSender.Spigot = new CommandSender.Spigot //override def spigot(): CommandSender.Spigot = new CommandSender.Spigot
override def spigot(): CommandSender.Spigot = ???
} }

View file

@ -4,9 +4,8 @@ import buttondevteam.discordplugin.DPUtils
import buttondevteam.lib.chat.Command2Sender import buttondevteam.lib.chat.Command2Sender
import discord4j.core.`object`.entity.channel.MessageChannel import discord4j.core.`object`.entity.channel.MessageChannel
import discord4j.core.`object`.entity.{Message, User} import discord4j.core.`object`.entity.{Message, User}
import lombok.RequiredArgsConstructor
@RequiredArgsConstructor class Command2DCSender(val message: Message) extends Command2Sender { class Command2DCSender(val message: Message) extends Command2Sender {
def getMessage: Message = this.message def getMessage: Message = this.message
override def sendMessage(message: String): Unit = { override def sendMessage(message: String): Unit = {

View file

@ -6,7 +6,6 @@ import buttondevteam.lib.TBMCSystemChatEvent
import discord4j.common.util.Snowflake import discord4j.common.util.Snowflake
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 lombok.NonNull
import javax.annotation.Nullable import javax.annotation.Nullable
import scala.collection.mutable.ListBuffer import scala.collection.mutable.ListBuffer
@ -59,8 +58,8 @@ object MCChatCustom {
def getCustomChats: List[CustomLMD] = lastmsgCustom.toList def getCustomChats: List[CustomLMD] = lastmsgCustom.toList
class CustomLMD private[mcchat](@NonNull channel: MessageChannel, @NonNull user: User, val groupID: String, class CustomLMD private[mcchat](channel: MessageChannel, user: User, val groupID: String,
@NonNull mcchannel: Channel, val dcp: DiscordConnectedPlayer, var toggles: Int, mcchannel: Channel, val dcp: DiscordConnectedPlayer, var toggles: Int,
var brtoggles: Set[TBMCSystemChatEvent.BroadcastTarget]) extends MCChatUtils.LastMsgData(channel, user, mcchannel) { var brtoggles: Set[TBMCSystemChatEvent.BroadcastTarget]) extends MCChatUtils.LastMsgData(channel, user, mcchannel) {
} }

View file

@ -1,7 +1,5 @@
package buttondevteam.discordplugin.playerfaker; package buttondevteam.discordplugin.playerfaker;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
@ -16,8 +14,7 @@ import java.util.stream.IntStream;
public class DiscordInventory implements Inventory { public class DiscordInventory implements Inventory {
private ItemStack[] items = new ItemStack[27]; private ItemStack[] items = new ItemStack[27];
private List<ItemStack> itemStacks = Arrays.asList(items); private List<ItemStack> itemStacks = Arrays.asList(items);
@Getter
@Setter
public int maxStackSize; public int maxStackSize;
private static ItemStack emptyStack = new ItemStack(Material.AIR, 0); private static ItemStack emptyStack = new ItemStack(Material.AIR, 0);
@ -26,6 +23,16 @@ public class DiscordInventory implements Inventory {
return items.length; return items.length;
} }
@Override
public int getMaxStackSize() {
return maxStackSize;
}
@Override
public void setMaxStackSize(int maxStackSize) {
this.maxStackSize = maxStackSize;
}
@Override @Override
public String getName() { public String getName() {
return "Discord inventory"; return "Discord inventory";

View file

@ -1,7 +1,6 @@
package buttondevteam.discordplugin.playerfaker package buttondevteam.discordplugin.playerfaker
import buttondevteam.discordplugin.{DiscordSenderBase, IMCPlayer} import buttondevteam.discordplugin.{DiscordSenderBase, IMCPlayer}
import lombok.Getter
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
@ -40,7 +39,7 @@ object VanillaCommandListener {
class VanillaCommandListener[T <: DiscordSenderBase with IMCPlayer[T]] extends ICommandListener { class VanillaCommandListener[T <: DiscordSenderBase with IMCPlayer[T]] extends ICommandListener {
def getPlayer: T = this.player def getPlayer: T = this.player
@Getter private var player: T = null.asInstanceOf private var player: T = null.asInstanceOf
private var bukkitplayer: Player = null private var bukkitplayer: Player = null
/** /**

View file

@ -1,7 +1,6 @@
package buttondevteam.discordplugin.playerfaker package buttondevteam.discordplugin.playerfaker
import buttondevteam.discordplugin.{DiscordSenderBase, IMCPlayer} import buttondevteam.discordplugin.{DiscordSenderBase, IMCPlayer}
import lombok.Getter
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
@ -44,7 +43,7 @@ object VanillaCommandListener14 {
class VanillaCommandListener14[T <: DiscordSenderBase with IMCPlayer[T]] extends ICommandListener { class VanillaCommandListener14[T <: DiscordSenderBase with IMCPlayer[T]] extends ICommandListener {
def getPlayer: T = this.player def getPlayer: T = this.player
@Getter private var player: T = null.asInstanceOf private var player: T = null.asInstanceOf
private var bukkitplayer: Player = null private var bukkitplayer: Player = null
/** /**