简体   繁体   English

无法解析符号“dispactCommand”错误

[英]Cannot resolve symbol 'dispactCommand' Error

 package me.cvn.secondplugin.secondplugin.commands; import org.bukkit.Bukkit; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.event.Listener; public class nick implements Listener { ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); Bukkit.dispatchCommand(console, "say Test"); }

In this script, dispatchCommand gets red format saying "Cannot resolve symbol 'dispatchCommand'" in it.在此脚本中,dispatchCommand 以红色格式显示“无法解析符号‘dispatchCommand’”。 I searched some but couldn't get any answer for this.我搜索了一些但无法得到任何答案。

You have to include lines in a method like this:您必须在这样的方法中包含行:

package me.cvn.secondplugin.secondplugin.commands;

public class nick implements Listener {

   @EventHandler
   public void myListener(PlayerJoinEvent e) { // even when player join
      ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
      Bukkit.dispatchCommand(console, "say Test");
   }
}

 package me.cvn.secondplugin.secondplugin.commands; import org.bukkit.Bukkit; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.event.Listener; public class nick implements Listener { ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); Bukkit.dispatchCommand(console, "say Test"); }

In this script, dispatchCommand gets red format saying "Cannot resolve symbol 'dispatchCommand'" in it.在这个脚本中,dispatchCommand 得到红色格式,其中显示“无法解析符号'dispatchCommand'”。 I searched some but couldn't get any answer for this.我搜索了一些,但没有得到任何答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM