布基特 java.lang.NoSuchMethodError

bukkit java.lang.NoSuchMethodError

全部。我一直遇到这个问题,显然我引用了一个不存在的方法。 IDE 没有标记任何东西是坏的,所以我有点迷路了。我已经尝试了几件事,但它们似乎没有用。这是一项正在进行的工作,因此并非一切都已完成,但它应该仍然有效。无论如何,这是主要的 class:

package me.xeyler;

import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class MazeMain extends JavaPlugin{

@Override
public void onEnable() {

    new EventHandle(this);

    File file = new File(getDataFolder(), "config.yml");
    if(!file.exists()) {

        getLogger().info("Generating config.yml...");
        saveDefaultConfig();

    }

    getLogger().info("MinecraftMazer has been enabled!");

}

@Override
public void onDisable() {

    getLogger().info("MinecraftMazer has been disabled!");

}

public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    if(cmd.getName().equalsIgnoreCase("makemaze")) {

        if(!(sender instanceof Player)) {
            sender.sendMessage(ChatColor.RED + "You must be a player to preform this command!");
        } else {
            Player player = (Player) sender;

            MazeGenerator maze = new MazeGenerator();
            //maze.generate(width, length, height, sender);

        }

        }

    return false;

}



public class MazeGenerator {

public void generate( int width, int length, int height, Player sender ) {



}

}
}

当然还有 "non-existent" class 和 "non-existent" 方法:

package me.xeyler;

import java.util.HashMap;

import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;

public class EventHandle implements Listener {

MazeMain Plugin;

public EventHandle(MazeMain plugin) {

    plugin.getServer().getPluginManager().registerEvents(this, plugin);
    Plugin = plugin;

}

//setting some variables
private HashMap<Player, Location> start = new HashMap<Player, Location>();
private HashMap<Player, Location> end = new HashMap<Player, Location>();

//THESE VARIABLES WILL BE USED LATER FOR MARKING THE ENTRANCE AND EXIT TO A MAZE
//private HashMap<Player, Location> entrance = new HashMap<Player, Location>();
//private HashMap<Player, Location> exit = new HashMap<Player, Location>();

HashMap<Player, BlockState> startBlock = new HashMap<Player, BlockState>();
HashMap<Player, BlockState> endBlock = new HashMap<Player, BlockState>();
HashMap<Player, BlockState> entranceBlock = new HashMap<Player, BlockState>();
HashMap<Player, BlockState> exitBlock = new HashMap<Player, BlockState>();

ChatColor green = ChatColor.GREEN;
ChatColor red = ChatColor.RED;
ChatColor yellow = ChatColor.YELLOW;
ChatColor blue = ChatColor.BLUE;

@SuppressWarnings("deprecation")
@EventHandler
public void onMarkBlock(PlayerInteractEvent event) {

    Player player = event.getPlayer();

    if (player.hasPermission("MinecraftMazer.allowed")) {

        if (player.getItemInHand().getType().toString().equalsIgnoreCase(Plugin.getConfig().getString("selectTool"))) {

        if (event.getAction() == Action.LEFT_CLICK_BLOCK) {

                event.setCancelled(true);

                if (startBlock.get(player) != null) {

                    Location oldLoc = start.get(player);
                    BlockState oldBlock = startBlock.get(player);
                    oldLoc.getBlock().setType(oldBlock.getType());
                    oldLoc.getBlock().getState().setData(oldBlock.getData());
                    oldBlock.update(false, false);

                }

                start.put(player, event.getClickedBlock().getLocation());

                if (Plugin.getConfig().getBoolean("markSelections")) {
                startBlock.put(player, (event.getClickedBlock().getState()));
                event.getClickedBlock().setType(org.bukkit.Material.WOOL);
                event.getClickedBlock().setData((byte) 0);

                }

                int x = (int) start.get(player).getX();
                int y = (int) start.get(player).getY();
                int z = (int) start.get(player).getZ();

                player.sendMessage(yellow + "Position one set as " + red + x + ", " + green + y + ", " + blue + z);
                player.getWorld().playSound(player.getLocation(), Sound.ORB_PICKUP, 20, 1);

            }

        }

        if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {

            if (endBlock.get(player) != null) {

                Location oldLoc2 = end.get(player);
                BlockState oldBlock2 = endBlock.get(player);
                oldLoc2.getBlock().setType(oldBlock2.getType());
                oldLoc2.getBlock().getState().setData(oldBlock2.getData());
                oldBlock2.update(false, false);

            }
                end.put(player, event.getClickedBlock().getLocation());
                if (Plugin.getConfig().getBoolean("markSelections")) {
                endBlock.put(player, event.getClickedBlock().getState());
                event.getClickedBlock().setType(org.bukkit.Material.WOOL);
                event.getClickedBlock().setData((byte) 15);
                }

                int x = (int) end.get(player).getX();
                int y = (int) end.get(player).getY();
                int z = (int) end.get(player).getZ();

                player.sendMessage(yellow + "Position two set as " + red + x + ", " + green + y + ", " + blue + z);
                player.getWorld().playSound(player.getLocation(), Sound.ORB_PICKUP, 20, 1);

            }

        }

    }


}

还有...击鼓声,拜托! dum da-dum 无所不能的错误:

java.lang.NoSuchMethodError: me.xeyler.EventHandle.<init>(Lme/xeyler/MazeMain;)V
    at me.xeyler.MazeMain.onEnable(MazeMain.java:15) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:316) ~[spigot1658.jar:git-Spigot-"606148f"]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:333) [spigot1658.jar:git-Spigot-"606148f"]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:412) [spigot1658.jar:git-Spigot-"606148f"]
    at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugin(CraftServer.java:352) [spigot1658.jar:git-Spigot-"606148f"]
    at org.bukkit.craftbukkit.v1_8_R1.CraftServer.enablePlugins(CraftServer.java:313) [spigot1658.jar:git-Spigot-"606148f"]
    at org.bukkit.craftbukkit.v1_8_R1.CraftServer.reload(CraftServer.java:742) [spigot1658.jar:git-Spigot-"606148f"]
    at org.bukkit.Bukkit.reload(Bukkit.java:301) [spigot1658.jar:git-Spigot-"606148f"]
    at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) [spigot1658.jar:git-Spigot-"606148f"]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:181) [spigot1658.jar:git-Spigot-"606148f"]
    at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServer.java:643) [spigot1658.jar:git-Spigot-"606148f"]
    at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchServerCommand(CraftServer.java:629) [spigot1658.jar:git-Spigot-"606148f"]
    at net.minecraft.server.v1_8_R1.DedicatedServer.aM(DedicatedServer.java:353) [spigot1658.jar:git-Spigot-"606148f"]
    at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:317) [spigot1658.jar:git-Spigot-"606148f"]
    at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:625) [spigot1658.jar:git-Spigot-"606148f"]
    at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:528) [spigot1658.jar:git-Spigot-"606148f"]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_45]

感谢你们解决了我愚蠢但希望很容易解决的问题,伙计们!你是最棒的!

问题

尝试从侦听器中删除构造函数。

在你的主要 class:

 private static MazeMain instance;

 // Does not need override
 public void onEnable(){
     PluginManager manager = Bukkit.getPluginManager();
     manager.registerEvents(new EventHandle(), this);

     // Make the instance of this class available for other classes
     instance = this;

     // Your config generator

     // You don't need to log enabling and disabling
     // ^(Bukkit does that automatically)

 }

 public void onDisable(){
     instance = null;
 }

 public static MazeMain getInstance(){
     return instance;
 }

在你的监听器中,删除这个:

public EventHandle(MazeMain plugin){
    plugin.getServer().getPluginManager().registerEvents(this, plugin);
    Plugin = plugin;
}

另外,把

全部改掉
 Plugin.getConfig()

 MazeMain.getInstance().getConfig()

额外

永远不要存储玩家和位置对象! 就像方块对象一样,它非常重并且会导致内存泄漏。如果你不想要大量的滞后,我建议你将对象转换为 string/UUID.

Player: Player.getUniqueId() 会给你 UUID,然后你可以做 Bukkit.getPlayer(UUID) 再次获取 Player 对象(记得检查对象是否不为空)。

位置:存储世界name/UID,x, y, z, yaw, pitch 在一个字符串中,由一个字符分隔。通过拆分字符串将其变成一个对象并实例化一个新的 Location。如果您只是要保留方块的位置,那么在这种情况下您不需要偏航和俯仰(它与玩家的视线有关)。

请记住 classes 中的 private/public/protected 标志。

您应该修复弃用问题,因为它很快就会失去支持。由于有更好的解决方案,它正在失去支持。

此外,为什么要将 ChatColors 存储在变量中?

希望以上内容对您有所帮助!欢迎提出更多问题! :)

(我解释的很烂)