Java.lang.NoSuchMethodError when clear there

General information: I use the Bukkit / Spigot API in git version -Spigot-1d14d5f-ba32592 (MC: 1.8.3) (Implementation of API version 1.8.3-R0.1 -SNAPSHOT), IntelliJ IDEA 14.1.3 and compilation with its compiler default. The java jdk version is 1.8.0_25.

Therefore, when I try to call this class constructor, it throws an exception from the runtime.

Inventory Menu Class

package me.lakan.util.inventory; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import java.util.HashMap; import java.util.Map; @SuppressWarnings("unused") // Util functionality is not always used public class InventoryMenu implements Listener { private InventoryType type; private String title; private Map<Integer, MenuOption> options; // Constructors public InventoryMenu(InventoryType type, String title, JavaPlugin plugin) { this.options = new HashMap<Integer, MenuOption>(); this.type = type; this.title = title; plugin.getServer().getPluginManager().registerEvents(this, plugin); } public boolean addOption(int position, MenuOption option) { boolean res = isPosEmpty(position); this.options.put(position, option); return res; } public void addOption(String name, int position, ItemStack icon) { addOption(position, new MenuOption(icon, name)); } public boolean isPosEmpty(int position) { return !this.options.containsKey(position); } public void openFor(Player p) { // Create a new inventory Inventory inv = Bukkit.createInventory(p, this.type, this.title); // Fill all icons at their positions for (Map.Entry<Integer, MenuOption> key : this.options.entrySet()) { inv.setItem(key.getKey(), key.getValue().getIcon()); } // If the inventory is a player inventory, update the player's if (inv.getType() == InventoryType.PLAYER) { p.getInventory().setContents(inv.getContents()); } // For any openable inventory, just open it up else { p.openInventory(inv); } } /** * Listens for inventory clicks * If the inventory is a menu: * - Cancel movement * - Push event * - Close inventory if it should * @param e The actual event */ @EventHandler(priority = EventPriority.HIGHEST) public void onInventoryClick(InventoryClickEvent e) { // Prevent clicking if this inventory was clicked if (e.getClickedInventory().getName().equals(this.title)) { e.setCancelled(true); // Check for option if (this.options.containsKey(e.getRawSlot())) { // Get the option for this slot MenuOption option = this.options.get(e.getRawSlot()); // Fill out an event and push it MenuClickEvent event = new MenuClickEvent((Player) e.getWhoClicked(), true, option.getName(), e.getRawSlot()); Bukkit.getServer().getPluginManager().callEvent(event); // Now close inventory if not cancelled if (event.willCLose()) { e.getWhoClicked().closeInventory(); } } } } @SuppressWarnings("unused") public interface OptionClickEventHandler { public void onOptionClick(MenuClickEvent event); } } 

Product Menu Class

 package me.lakan.test; import me.lakan.util.inventory.InventoryMenu; import me.lakan.util.inventory.MenuClickEvent; import me.lakan.util.inventory.MenuOption; import me.lakan.util.item.ItemBuilder; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryType; public class ItemMenu implements Listener { private PluginEntry plugin; private InventoryMenu menu; // Commands private TestCommand testCmd; public ItemMenu(PluginEntry plugin) { Validate.notNull(this.plugin, "The plugin reference may not be null"); this.plugin = plugin; this.menu = new InventoryMenu(InventoryType.CHEST, "" + ChatColor.DARK_GRAY + "Abilities", this.plugin); // Test this.menu.addOption(1, new MenuOption( new ItemBuilder() .amount(1) .material(Material.RAW_FISH) .name(ChatColor.LIGHT_PURPLE + "Test") .lore(ChatColor.WHITE + "Click me") .build(), "TestIdentifier")); this.testCmd= new TestCmd(this.plugin); } public void openFor(Player p) { this.menu.openFor(p); } @EventHandler(priority = EventPriority.NORMAL) public void onOptionClick(MenuClickEvent e) { // Test if (e.getName().equals("TestIdentifier")) { this.testCmd.executeFor(e.getWhoClicked()); } } } 

Exception stack trace

[12:48:25] [Server thread / ERROR]: An error occurred while turning on the v1.0 test (is it updated?) Java.lang.NoSuchMethodError: me.lakan.util.inventory.InventoryMenu. (Lorg / bukkit / event / inventory / InventoryType; Ljava / lang / String; Lorg / bukkit / plugin / java / JavaPlugin;) V

at me.lakan.test.ItemMenu. (ItemMenu.java:33) ~ [?:?] At me.lakan.test.CommandParser. (CommandParser.java:20) ~ [?:?] At me.lakan.test.PluginEntry.onEnable (PluginEntry.java21) ~ [?:?] At org.bukkit.plugin.java.JavaPlugin.setEnabled (JavaPlugin.java : 321) ~ [spigot_server.jar: git -Spigot-1d14d5f-ba32592] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin (JavaPluginLoader.javahaps35) [spigot_server.jar: git-bp145 org.bukkit.plugin.SimplePluginManager.enablePlugin (SimplePluginManager.java:405) [spigot_server.jar: git -Spigot-1d14d5f-ba32592] at org.bukkit.craftbukkit.v1_8_R2._vertervergtercraft .jar: git -Spigot-1d14d5f-ba32592] on org.bukkit.craftbukkit.v1_8_R2.CraftServer.enablePlugins (CraftServer.javahaps16) [spigot_server.jar: git -Spigot-1d14d5fer ba net.er32 v1_8_R2.MinecraftServer.r (MinecraftServer.javarige16) [spigot_server.jar: git -Spigot-1d14d5f-ba32592] at net.minecraft.server.v1_8_R2.MinecraftServer.k (MinecraftServer.javaars ger [sp. -Spigot-1 d14d5f-ba32592] at net.minecraft.server.v1_8_R2.MinecraftServer.a (MinecraftServer.javahaps37) [spigot_server.jar: git -Spigot-1d14d5f-ba32592] at net.minecraft.server.v1_8erDerved.er1ed_erver.Dedicated .java: 257) [spigot_server.jar: git -Spigot-1d14d5f-ba32592] in net.minecraft.server.v1_8_R2.MinecraftServer.run (MinecraftServer.javahaps22) [spigot_server.jar: git -Spigf-1 bdp5f-1 in java.lang.Thread.run (Unknown source) [?: 1.8.0_31]

As you can see, there is a constructor and, as far as I know, it’s called correctly. So is this error an error in my project setup, API, or something completely different?

The class utilities are in a separate module, and everything works if I insert them into the module of the test plugin, but not inside another module. However, any other constructor in any other class inside me.lakan.util.inventory can be called normally.

+8
java constructor exception bukkit
source share
1 answer

The problem was in the structure of the project.

For the test artifact, I chose the module module module util. Fixed its change to the output of the utility module artifact .

+3
source share

All Articles