LingerJAB 发布的帖子
-
RE: 使用Quartz依赖不能启动Mirai
@cssxsh 我的机器人主程序 MiraiBot.java:
import ... public final class MiraiBot extends JavaPlugin { public static final MiraiBot INSTANCE = new MiraiBot(); private MiraiBot() { super(new JvmPluginDescriptionBuilder("com.mirai.lin", "0.1.0") .name("MiraiBot") .author("Lin") .build()); } @Override public void onEnable() { // 就像下面这样 ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(Bootstrap.class.getClassLoader()); // Service loading. getLogger().info("Plugin loaded!"); EventChannel<Event> channel = GlobalEventChannel.INSTANCE .parentScope(MiraiBot.INSTANCE) .context(this.getCoroutineContext()); // 加载 DcConfig MainHandler.loadTokens(); // Token刷新器 autoRefreshToken(); // 监听器 channel.subscribeAlways(MessageEvent.class, MainHandler::eventCenter); } finally { Thread.currentThread().setContextClassLoader(old); } } // 自动刷新Token public void autoRefreshToken() { Scheduler scheduler; try { scheduler = new StdSchedulerFactory().getScheduler(); } catch(SchedulerException e) { throw new RuntimeException(e); } JobDetail jobDetail = JobBuilder.newJob(RefreshTokenJob.class).build(); Trigger trigger = TriggerBuilder.newTrigger().startNow().withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(30)).build(); try { scheduler.scheduleJob(jobDetail, trigger); scheduler.start(); } catch(SchedulerException e) { throw new RuntimeException(e); } @Deprecated public void refreshTokensTimer(){...} }
-
RE: 使用Quartz依赖不能启动Mirai
@cssxsh 这两次的报错是一样的...
此外我在debug时发现并没有执行更换类加载器的代码,不知道是不是真的只是quartz库的问题(可是我明明gradle依赖了呀💦💦) -
RE: 使用Quartz依赖不能启动Mirai
@cssxsh 未能解决,请问这里的类加载器的插件不是当前使用的Bot吗(我这里是MiraiBot extends JavaPlugin),使用JavaPlugin.class也能没能解决
现在不清楚是解决方案的那一步出了问题
这里是报错信息2023-12-08 00:23:42 E/main: Failed to init MiraiConsole. net.mamoe.mirai.console.internal.util.ServiceLoadException: Could not load service com.mirai.MiraiBot. at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadService(PluginServiceHelper.kt:60) at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadAllServices(PluginServiceHelper.kt:42) at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl$extractPlugins$findAllInstances$2.invoke(BuiltInJvmPluginLoaderImpl.kt:170) at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl$extractPlugins$findAllInstances$2.invoke(BuiltInJvmPluginLoaderImpl.kt:165) at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210) at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:314) at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:303) at kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:214) at kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:214) at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:316) at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:303) at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:786) at kotlin.sequences.SequencesKt___SequencesKt.toSet(_Sequences.kt:827) at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.extractPlugins(BuiltInJvmPluginLoaderImpl.kt:191) at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.listPlugins(BuiltInJvmPluginLoaderImpl.kt:66) at net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader$BuiltIn.listPlugins(JvmPluginLoader.kt) at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.listAndSortAllPlugins(PluginManagerImpl.kt:192) at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.findAndSortAllPluginsUsingBuiltInLoaders(PluginManagerImpl.kt:138) at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.loadAllPluginsUsingBuiltInLoaders$mirai_console(PluginManagerImpl.kt:148) at net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge.doStart$mirai_console(MiraiConsoleImplementationBridge.kt:178) at net.mamoe.mirai.console.MiraiConsoleImplementation$Companion.start(MiraiConsoleImplementation.kt:464) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon(MiraiConsoleTerminalLoader.kt:168) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon$default(MiraiConsoleTerminalLoader.kt:167) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.main(MiraiConsoleTerminalLoader.kt:52) Caused by: java.lang.NoClassDefFoundError: org/quartz/SchedulerException at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:467) at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadService(PluginServiceHelper.kt:51) Caused by: java.lang.NoClassDefFoundError: org/quartz/SchedulerException ... 23 more Caused by: java.lang.ClassNotFoundException: org.quartz.SchedulerException at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) Caused by: java.lang.ClassNotFoundException: org.quartz.SchedulerException at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) at net.mamoe.mirai.console.internal.plugin.JvmPluginClassLoaderN.loadClass(JvmPluginClassLoader.kt:389) ... 26 more
-
使用Quartz依赖不能启动Mirai
使用了该依赖无法启动
implementation 'org.quartz-scheduler:quartz:2.3.2'
报错没找到类,但我IDEA下jar外部包都能找到,而且引用没有问题2023-12-07 01:19:44 E/main: Failed to init MiraiConsole. net.mamoe.mirai.console.internal.util.ServiceLoadException: Could not load service com.mirai.MiraiBot. at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadService(PluginServiceHelper.kt:60) at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadAllServices(PluginServiceHelper.kt:42) at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl$extractPlugins$findAllInstances$2.invoke(BuiltInJvmPluginLoaderImpl.kt:170) at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl$extractPlugins$findAllInstances$2.invoke(BuiltInJvmPluginLoaderImpl.kt:165) at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210) at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:314) at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:303) at kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:214) at kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:214) at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:316) at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:303) at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:786) at kotlin.sequences.SequencesKt___SequencesKt.toSet(_Sequences.kt:827) at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.extractPlugins(BuiltInJvmPluginLoaderImpl.kt:191) at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.listPlugins(BuiltInJvmPluginLoaderImpl.kt:66) at net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader$BuiltIn.listPlugins(JvmPluginLoader.kt) at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.listAndSortAllPlugins(PluginManagerImpl.kt:192) at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.findAndSortAllPluginsUsingBuiltInLoaders(PluginManagerImpl.kt:138) at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.loadAllPluginsUsingBuiltInLoaders$mirai_console(PluginManagerImpl.kt:148) at net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge.doStart$mirai_console(MiraiConsoleImplementationBridge.kt:178) at net.mamoe.mirai.console.MiraiConsoleImplementation$Companion.start(MiraiConsoleImplementation.kt:464) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon(MiraiConsoleTerminalLoader.kt:168) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon$default(MiraiConsoleTerminalLoader.kt:167) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.main(MiraiConsoleTerminalLoader.kt:52) Caused by: java.lang.NoClassDefFoundError: org/quartz/SchedulerException at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:488) at java.base/java.lang.Class.forName(Class.java:467) at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadService(PluginServiceHelper.kt:51) ... 23 more Caused by: java.lang.NoClassDefFoundError: org/quartz/SchedulerException Caused by: java.lang.ClassNotFoundException: org.quartz.SchedulerException at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at net.mamoe.mirai.console.internal.plugin.JvmPluginClassLoaderN.loadClass(JvmPluginClassLoader.kt:389) ... 27 more Caused by: java.lang.ClassNotFoundException: org.quartz.SchedulerException
-
如何用java异步只阻塞当前事件处理器
(kotlin,java多线程小白💦💦可能很多术语不太会说很抱歉
需求:异步发送两个http请求,阻塞获取两个值返回进行处理
我写了一个CompletableFuture future
问题:我在event监听器处理的时候调用future.join()和future.get()并不能阻塞event处理,导致get没有返回造成NullPointException,我想知道join会不会阻塞subcribleAlways(...)和单个event处理线程
这个在kotlin里面叫做协程吧,类似这样的需求在java里面怎么实现
-
RE: image-combiner 一个快捷制图的库
@2623277496 addImageElement(Image, Width, Height, Zoom)这个方法也可以
-
RE: image-combiner 一个快捷制图的库
如果JDK8以上出现create()报错的,是因为没有sun包,需要改一下jvm参数,具体参考这个帖子
https://blog.csdn.net/u012448758/article/details/125689992 -
image-combiner 一个快捷制图的库
https://gitee.com/dromara/image-combiner
不是我做的,以下从README复制的
1.1 项目背景
最近公司上了不少传播方面的需求,免不了合成各种营销图片,图片合成本身并不是什么高深的技术,但用底层api去搞确实繁琐,于是抽时间封装了一个小工具,初衷是解放生产力,后来发现挺好使,那就开源吧,花了一个整天重新整理了一下代码,作为自己从业十年第一个开源项目(打破零记录,哈哈),希望能够帮助到需要的小伙伴~1.2 ImageCombiner能够做什么?
ImageCombiner是一个专门用于Java服务端图片合成的工具,没有很复杂的功能,简单实用,从实际业务场景出发,提供简单的接口,几行代码即可实现图片拼合(当然用于合成水印也可以),素材上支持图片、文本、矩形三种,支持定位、缩放、旋转、圆角、透明度、颜色、字体、字号、删除线、居中绘制、文本自动换行等特性,足够覆盖图片合成的日常需求。1.3 先看一下效果
基本功能展示(更多效果可自行探索)
avater专门开了一个作品搜集&展示的issue,可以秀一秀成果,顺带分享下思路~