Skocz do zawartości

LegalPL

Użytkownik
  • Liczba zawartości

    1
  • Rejestracja

  • Ostatnia wizyta

Reputacja

0 Neutralny

O LegalPL

  • Tytuł
    Nowy
  1. Witam! Pisząc plugin tworzący gui napotkałem błąd, podczas gdy klikam w gui na puste pole, w konsoli wyświetla taki oto error: [13:39:16 ERROR]: Could not pass event InventoryClickEvent to LegalnyPlugin v1.0 java.lang.NullPointerException: null at takmain.Main.onMenuClick(Main.java:72) ~[?:?] at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor16.execute(Unknown Source) ~[?:?] at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[patched_1.15.2.jar:git-Paper-143] at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.15.2.jar:git-Paper-143] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.15.2.jar:git-Paper-143] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:559) ~[patched_1.15.2.jar:git-Paper-143] at net.minecraft.server.v1_15_R1.PlayerConnection.a(PlayerConnection.java:2333) ~[patched_1.15.2.jar:git-Paper-143] at net.minecraft.server.v1_15_R1.PacketPlayInWindowClick.a(SourceFile:32) ~[patched_1.15.2.jar:git-Paper-143] at net.minecraft.server.v1_15_R1.PacketPlayInWindowClick.a(SourceFile:10) ~[patched_1.15.2.jar:git-Paper-143] at net.minecraft.server.v1_15_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:23) ~[patched_1.15.2.jar:git-Paper-143] at net.minecraft.server.v1_15_R1.TickTask.run(SourceFile:18) ~[patched_1.15.2.jar:git-Paper-143] at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.15.2.jar:git-Paper-143] at net.minecraft.server.v1_15_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.15.2.jar:git-Paper-143] at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[patched_1.15.2.jar:git-Paper-143] at net.minecraft.server.v1_15_R1.MinecraftServer.ba(MinecraftServer.java:1038) ~[patched_1.15.2.jar:git-Paper-143] at net.minecraft.server.v1_15_R1.MinecraftServer.executeNext(MinecraftServer.java:1031) ~[patched_1.15.2.jar:git-Paper-143] at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[patched_1.15.2.jar:git-Paper-143] at net.minecraft.server.v1_15_R1.MinecraftServer.sleepForTick(MinecraftServer.java:1015) ~[patched_1.15.2.jar:git-Paper-143] at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:938) ~[patched_1.15.2.jar:git-Paper-143] at java.lang.Thread.run(Unknown Source) [?:1.8.0_241] A oto mój kod pluginu: package takmain; import java.util.ArrayList; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; 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.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; public class Main extends JavaPlugin implements Listener{ ArrayList<String> red = new ArrayList<String>(); ArrayList<String> blue = new ArrayList<String>(); public void onEnable() { getServer().getPluginManager().registerEvents(this, this); } private void openGUI(Player player) { Inventory inv = Bukkit.createInventory(null, 9, ChatColor.YELLOW + "Wybierz drużynę!"); ItemStack blue = new ItemStack(Material.BLUE_WOOL); ItemStack red = new ItemStack(Material.RED_WOOL); ItemMeta blueMeta = blue.getItemMeta(); ItemMeta redMeta = red.getItemMeta(); blueMeta.setDisplayName(ChatColor.BLUE + "Drużyna niebieska"); redMeta.setDisplayName(ChatColor.RED + "Drużyna czerwona"); blue.setItemMeta(blueMeta); red.setItemMeta(redMeta); inv.setItem(3, blue); inv.setItem(5, red); player.openInventory(inv); } @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { event.getPlayer().getInventory().clear(); ItemStack item = new ItemStack(Material.NETHER_STAR, 1); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(ChatColor.YELLOW + "Wybierz drużynę!"); item.setItemMeta(meta); event.getPlayer().getInventory().setItem(4, item); } @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if(event.getItem() != null && event.getItem().getItemMeta().getDisplayName() != null){ if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.PHYSICAL) { if (event.getItem().getType() == Material.NETHER_STAR){ if (event.getItem().getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Wybierz drużynę!")){ openGUI(event.getPlayer()); } } } } } @EventHandler public void onMenuClick(InventoryClickEvent e){ if (e.getWhoClicked() instanceof Player) { if (e.getView().getTitle().equalsIgnoreCase(ChatColor.YELLOW + "Wybierz drużynę!")) { if (e.getCurrentItem().getType() == Material.BLUE_WOOL){ e.setCancelled(true); } }else if (e.getView().getTitle().equalsIgnoreCase(ChatColor.YELLOW + "Eluwina")) { if (e.getCurrentItem().getType() == Material.BLUE_WOOL){ e.setCancelled(true); } } return; } } } Mam nadzieję, że coś poradzicie Pozdrawiam!

Główny

Główny

Wprowadź swoją nazwę

×
×
  • Dodaj nową pozycję...