Closed freeze-dolphin closed 3 years ago
Note that I am using RedLib to write commands
The exception message is correct, classes in your scalaplugin are not provided by the PluginClassLoader from Bukkit, instead they are provided by the ScalaPluginClassLoader from ScalaLoader. RedLib is not aware of this possibility, and just assumes that every class of objects passed to its CommandCollection#register method is loaded from a JavaPlugin. If you wish to use RedLib to register your commands you'd need to find a different overload of #regsiter that allows you to pass the plugin instance explicitly. If such a method doesn't exist then somebody needs to PR this to RedLib, or you need to use a different way to create commands altogether.
Closing this issue as this is not a bug in ScalaLoader, but feel free to comment on it still if you want to say anything regarding this issue. I do read comments on closed issues.
Logs
Codes
Here are my codes
#### PlugGividado.scala ```scala package io.freeze_dolphin.plain_shop import io.freeze_dolphin.plain_shop.commands.CommandBus import io.freeze_dolphin.plain_shop.configs.ConfigBus import net.milkbowl.vault.economy.Economy import org.bukkit.plugin.Plugin import redempt.redlib.commandmanager.CommandParser import redempt.redlib.configmanager.ConfigManager import xyz.janboerman.scalaloader.plugin.ScalaPlugin import xyz.janboerman.scalaloader.plugin.description.{Scala, ScalaVersion} object PlugGividado { var pg: Plugin = _ var ec: Economy = _ var cg: ConfigManager = _ def getPrefix = "[PlainShop] " } @Scala(version = ScalaVersion.v2_13_6) class PlugGividado extends ScalaPlugin { override def onEnable(): Unit = { PlugGividado.pg = this if (!setupEconomy) { getLogger.severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription.getName)) getServer.getPluginManager.disablePlugin(this) return } new CommandParser(getResource("command.rdcml")).parse.register(getDescription.getName, new CommandBus()) PlugGividado.cg = new ConfigManager(this).register(new ConfigBus).saveDefaults.load getLogger.info("Loaded successfully!") } import net.milkbowl.vault.economy.Economy private def setupEconomy: Boolean = { if (getServer.getPluginManager.getPlugin("Vault") == null) return false val rsp = getServer.getServicesManager.getRegistration(classOf[Economy]) if (rsp == null) return false PlugGividado.ec = rsp.getProvider PlugGividado.ec != null } def getEc: Economy = PlugGividado.ec def getCg: ConfigManager = PlugGividado.cg } ``` #### CommandBus.scala ```scala package io.freeze_dolphin.plain_shop.commands import io.freeze_dolphin.plain_shop.PlugGividado import io.freeze_dolphin.plain_shop.commands.threads._ import io.freeze_dolphin.plain_shop.guis.UIUtl.color import org.bukkit.command.CommandSender import redempt.redlib.commandmanager.CommandHook class CommandBus { @CommandHook("put") def put(sender: CommandSender, id: String, category: String, prize: Float): Unit = { val th = new PutThread(sender, id, category, prize) th.start() } @CommandHook("pul") def pul(sender: CommandSender, id: String, category: String): Unit = { val th = new PullThread(sender, id, category) th.start() } @CommandHook("crt") def crt(sender: CommandSender, id: String, title: String, perm: String): Unit = { val th = new CrtThread(sender, id, title, perm) th.start() } @CommandHook("del") def del(sender: CommandSender, id: String): Unit = { val th = new DelThread(sender, id) th.start() } @CommandHook("opn") def opn(sender: CommandSender, category: String): Unit = { val th = new OpenThread(sender, category) th.start() } @CommandHook("lst") def lst(sender: CommandSender, id: Boolean, category: String): Unit = { val th = new ListThread(sender, id, category) th.start() } @CommandHook("rld") def rld(sender: CommandSender): Unit = { new Runnable() { override def run(): Unit = { PlugGividado.cg = PlugGividado.cg.load() } }.run() sender.sendMessage(color(PlugGividado.getPrefix + "&bDone in reloading!")) } } ```