Java Bukkit-Can';t同步启动RunTaskTimer();
我正在创建一个bukkit插件,但每隔几分钟发送一条消息时遇到了问题。它以前可以工作,但我现在使用的是bukkit 1.4.6测试版,现在不行了。前面的方法已被弃用,但它给了我相同的错误,所以我决定切换到它的替代品,没有运气 这是我的密码:Java Bukkit-Can';t同步启动RunTaskTimer();,java,plugins,timer,minecraft,bukkit,Java,Plugins,Timer,Minecraft,Bukkit,我正在创建一个bukkit插件,但每隔几分钟发送一条消息时遇到了问题。它以前可以工作,但我现在使用的是bukkit 1.4.6测试版,现在不行了。前面的方法已被弃用,但它给了我相同的错误,所以我决定切换到它的替代品,没有运气 这是我的密码: Bukkit.getServer().getScheduler().runTaskTimerAsynchronously((Plugin) this, new Runnable() { public void run() { Bukk
Bukkit.getServer().getScheduler().runTaskTimerAsynchronously((Plugin) this, new Runnable() {
public void run() {
Bukkit.broadcastMessage(ChatColor.DARK_PURPLE + "" + ChatColor.MAGIC + "aaaaaa" + ChatColor.RESET + " Important " + ChatColor.DARK_PURPLE + "" + ChatColor.MAGIC + "aaaaaa" + ChatColor.RESET + ":");
Bukkit.broadcastMessage("");
Bukkit.broadcastMessage(" Hacks are stricly prohibited. A list of approved mods is available on our website. Use of mods not approved by the arenacraft team may lead to a permanent ban.");
}}, 60L, 36000L);
}
我正在用它
控制台提供以下信息:
me.silvershad0wz.arenacraft.Notices (the class this code is from) Cannot be cast to org.bukkit.plugin.Plugin.
接着是许多错误。它来自于此
Bukkit.getServer().getScheduler().runTaskTimerAsynchronously((Plugin) this, new Runnable() {
线路
非常感谢您的帮助,因为我不知道“不能转换为”错误的含义。您是否从扩展JavaPlugin的主类调用调度程序?如果您没有,那么您将必须通过将其显示的
(plugin)this
位置更改为Bukkit.getServer().getPluginManager().getPlugin(“您的插件名称”)
是否从扩展JavaPlugin的主类调用调度程序?如果您不是,那么您将必须通过将其显示位置(this更改为Bukkit.getServer().getPluginManager().getPlugin(“您的插件名称”)
来获取插件的实例。插件的主类扩展了JavaPlugin,而不是plugin.:)
我认为简单的改变
.runTaskTimerAsynchronously((Plugin) this, new Runnable()
到
会起作用,甚至会
.runTaskTimerAsynchronously(this, new Runnable()
如果这是在主类中调用的
来源:插件的主类扩展了JavaPlugin,而不是plugin.:) 我认为简单的改变
.runTaskTimerAsynchronously((Plugin) this, new Runnable()
到
会起作用,甚至会
.runTaskTimerAsynchronously(this, new Runnable()
如果这是在主类中调用的
来源:非常感谢!那个代码以前是有用的,我真的很困惑。你是救命恩人,非常感谢!那个代码以前是有用的,我真的很困惑。你是救命恩人。