Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Internal Server Error - blad w wybieranym enchancie


Entify

Rekomendowane odpowiedzi

Opublikowano

Czesc, tak jak w temacie, klikam ppm na enchant, otwiera sie gui, jak klikne kilka razy na dolne sloty (sloty na samym dole z ksiazkami) to mnie wyrzuca i pisze "Internal server error"

errory z konsoli;

[16:31:31 WARN]: Failed to handle packet for /127.0.0.1:53897
java.lang.IndexOutOfBoundsException: Index: 50, Size: 45
        at java.util.ArrayList.rangeCheck(Unknown Source) ~[?:1.8.0_131]
        at java.util.ArrayList.get(Unknown Source) ~[?:1.8.0_131]
        at net.minecraft.server.v1_7_R4.Container.getSlot(Container.java:105) ~[
spigot.jar:git-PaperSpigot-43]
        at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java
:1516) ~[spigot.jar:git-PaperSpigot-43]
        at net.minecraft.server.v1_7_R4.PacketPlayInWindowClick.a(PacketPlayInWi
ndowClick.java:15) ~[spigot.jar:git-PaperSpigot-43]
        at net.minecraft.server.v1_7_R4.PacketPlayInWindowClick.handle(PacketPla
yInWindowClick.java:65) ~[spigot.jar:git-PaperSpigot-43]
        at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:189
) ~[spigot.jar:git-PaperSpigot-43]
        at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java
:81) [spigot.jar:git-PaperSpigot-43]
        at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:7
89) [spigot.jar:git-PaperSpigot-43]
        at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:3
07) [spigot.jar:git-PaperSpigot-43]
        at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:6
38) [spigot.jar:git-PaperSpigot-43]
        at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java
:544) [spigot.jar:git-PaperSpigot-43]
        at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:6
28) [spigot.jar:git-PaperSpigot-43]
[16:31:31 INFO]: Entify_ lost connection: Internal server error

Kod listenera:

package me.entify.enchant.listeners;

import javax.swing.text.Utilities;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
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;
import org.bukkit.inventory.ItemStack;
import me.entify.enchant.Main;
import me.entify.enchant.utils.EnchantAction;
import me.entify.enchant.utils.InventoryGUI;
import me.entify.enchant.utils.ItemBuilder1;
import me.entify.enchant.utils.Util;

public class CustomEnchantInventoryListener
  implements Listener
{
  private static ItemStack bookcase = new ItemBuilder1(Material.BOOKSHELF).setName(Util.fixColor("&e&lPropaCraft.PL")).toItemStack();
  private static ItemStack prot4 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOCHRONA IV")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n50 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n25"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack prot3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOCHRONA III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n30 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n15"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack prot2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOCHRONA II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n10"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack prot1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOCHRONA I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n10"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack fireprot4 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lODPORNOSC NA OGIEN IV")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n10"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack fireprot3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lODPORNOSC NA OGIEN III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n15 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n7"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack fireprot2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lODPORNOSC NA OGIEN II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n10 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n5"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack fireprot1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lODPORNOSC NA OGIEN I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n5 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n2"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack boomprot4 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOCHRONA PRZED WYBUCHEM IV")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n10"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack boomprot3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOCHRONA PRZED WYBUCHEM III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n15 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n7"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack boomprot2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOCHRONA PRZED WYBUCHEM II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n10 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n5"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack boomprot1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOCHRONA PRZED WYBUCHEM I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n5 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n2"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack projectileprot4 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOCHRONA PRZED POCISKAMI IV")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n10"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack projectileprot3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOCHRONA PRZED POCISKAMI III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n15 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n7"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack projectileprot2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOCHRONA PRZED POCISKAMI II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n10 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n5"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack projectileprot1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOCHRONA PRZED POCISKAMI I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n5 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n2"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack featherfall4 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lPOWOLNE OPADANIE IV")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n35 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n17"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack featherfall3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lPOWOLNE OPADANIE III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n30 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n15"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack featherfall2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lPOWOLNE OPADANIE II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n10"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack featherfall1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lPOWOLNE OPADANIE I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n15 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n7"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack unb2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lNIEZNISZCZALNOSC II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n30 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n15"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack unb1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lNIEZNISZCZALNOSC I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n10"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack respiration3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lODDYCHANIE III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n15 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n7"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack respiration2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lODDYCHANIE II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n10 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n5"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack respiration1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lODDYCHANIE I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n5 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n2"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack thorns3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lCIERNIE III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n25 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n12"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack thorns2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lCIERNIE II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n15 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n7"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack thorns1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lCIERNIE I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n10 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n5"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack aquafin1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lWYDAJNOSC POD WODA I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n10 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n5"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack eff5 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lWYDAJNOSC V")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n40 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n20"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack eff4 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lWYDAJNOSC IV")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n30 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n15"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack eff3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lWYDAJNOSC III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n10"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack eff2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lWYDAJNOSC II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n5 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n10"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack eff1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lWYDAJNOSC I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n5 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n2"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack fortune3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lSZCZESCIE III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n35 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n17"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack fortune2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lSZCZESCIE II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n25 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n12"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack fortune1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lSZCZESCIE I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n15 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n7"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack silk1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lJEDWABNY DOTYK I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n10"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack sharp5 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOSTROSC V")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n50 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n25"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack sharp4 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOSTROSC IV")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n40 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n20"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack sharp3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOSTROSC III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n30 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n15"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack sharp2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOSTROSC II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n10"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack sharp1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lOSTROSC I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n10 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n5"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack smite5 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lPOGROMCA NIEUMARLYCH V")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n30 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n15"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack smite4 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lPOGROMCA NIEUMARLYCH IV")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n25 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n12"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack smite3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lPOGROMCA NIEUMARLYCH III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n15 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n7"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack smite2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lPOGROMCA NIEUMARLYCH II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n10 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n5"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack smite1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lPOGROMCA NIEUMARLYCH I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n5 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n2"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack bane5 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lZMORA STAWONOGOW V")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n15"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack bane4 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lZMORA STAWONOGOW IV")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n25 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n12"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack bane3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lZMORA STAWONOGOW III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n15 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n7"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack bane2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lZMORA STAWONOGOW II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n10 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n5"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack bane1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lZMORA STAWONOGOW I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n5 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n2"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack looting3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lGRABIEZ III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n35 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n17"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack looting2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lGRABIEZ II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n25 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n12"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack looting1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lGRABIEZ I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n15 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n7"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack fireasp2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lZAKLETY OGIEN II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n40 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n20"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack fireasp1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lZAKLETY OGIEN I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n10"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack knock2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lODRZUT II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n30 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n15"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack knock1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lODRZUT I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n15 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n7"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack power6 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lMOC VI")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n60 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n30"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack power5 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lMOC V")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n50 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n25"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack power4 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lMOC IV")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n40 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n20"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack power3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lMOC III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n30 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n15"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack power2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lMOC II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n10"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack power1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lMOC I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n10 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n5"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack infinity1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lNIESKONCZONOSC I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n15"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack plomien3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lPLOMIEN III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n30 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n25"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack plomien2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lPLOMIEN II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n20"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack plomien1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lPLOMIEN I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n10 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n15"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack punch3 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lODRZUT III")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n30 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n25"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack punch2 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lODRZUT II")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n20 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n20"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static ItemStack punch1 = new ItemBuilder1(Material.ENCHANTED_BOOK).setName(Util.fixColor("&a&lODRZUT I")).setLore(new String[] { Util.fixColor(""), Util.fixColor(" &8» &7Koszt: &a&n10 LvL"), Util.fixColor(""), Util.fixColor(" &8» &7Wymagane biblioteczki: &a&n15"), Util.fixColor(""), Util.fixColor(" &8»     &6&nKLIKNIJ BY ZACZAROWAC&r      ") }).toItemStack();
  private static InventoryGUI gui;
  
  public static boolean isAllowedEnchant(ItemStack item, Enchantment e)
  {
    return e.canEnchantItem(item);
  }
  
  public static void openEnchant(Player p, int books, ItemStack item)
  {
    gui = new InventoryGUI(Main.getInstance(), Util.fixColor("&aAktywne biblioteczki: &a" + books), 6);
    if (getEnchantmentPartTypeForItemStack(item) == EnchantType.ARMOR)
    {
      gui.setItem(19, prot4, new EnchantAction(Enchantment.PROTECTION_ENVIRONMENTAL, 4, 50, 25, books));
      gui.setItem(28, prot3, new EnchantAction(Enchantment.PROTECTION_ENVIRONMENTAL, 3, 30, 15, books));
      gui.setItem(37, prot2, new EnchantAction(Enchantment.PROTECTION_ENVIRONMENTAL, 2, 20, 10, books));
      gui.setItem(46, prot1, new EnchantAction(Enchantment.PROTECTION_ENVIRONMENTAL, 1, 15, 7, books));
      gui.setItem(20, fireprot4, new EnchantAction(Enchantment.PROTECTION_FIRE, 4, 20, 10, books));
      gui.setItem(29, fireprot3, new EnchantAction(Enchantment.PROTECTION_FIRE, 3, 15, 7, books));
      gui.setItem(38, fireprot2, new EnchantAction(Enchantment.PROTECTION_FIRE, 2, 10, 5, books));
      gui.setItem(47, fireprot1, new EnchantAction(Enchantment.PROTECTION_FIRE, 1, 5, 2, books));
      gui.setItem(21, boomprot4, new EnchantAction(Enchantment.PROTECTION_EXPLOSIONS, 4, 20, 10, books));
      gui.setItem(30, boomprot3, new EnchantAction(Enchantment.PROTECTION_EXPLOSIONS, 3, 15, 7, books));
      gui.setItem(39, boomprot2, new EnchantAction(Enchantment.PROTECTION_EXPLOSIONS, 2, 10, 5, books));
      gui.setItem(48, boomprot1, new EnchantAction(Enchantment.PROTECTION_EXPLOSIONS, 1, 5, 2, books));
      gui.setItem(22, projectileprot4, new EnchantAction(Enchantment.PROTECTION_PROJECTILE, 4, 20, 10, books));
      gui.setItem(31, projectileprot3, new EnchantAction(Enchantment.PROTECTION_PROJECTILE, 3, 15, 7, books));
      gui.setItem(40, projectileprot2, new EnchantAction(Enchantment.PROTECTION_PROJECTILE, 2, 10, 5, books));
      gui.setItem(49, projectileprot1, new EnchantAction(Enchantment.PROTECTION_PROJECTILE, 1, 5, 2, books));
      if (getEnchantTypeForItemStack(item) == EnchantType.BOOTS)
      {
        gui.setItem(23, featherfall4, new EnchantAction(Enchantment.PROTECTION_FALL, 4, 35, 17, books));
        gui.setItem(32, featherfall3, new EnchantAction(Enchantment.PROTECTION_FALL, 3, 30, 15, books));
        gui.setItem(41, featherfall2, new EnchantAction(Enchantment.PROTECTION_FALL, 2, 15, 7, books));
        gui.setItem(50, featherfall1, new EnchantAction(Enchantment.PROTECTION_FALL, 1, 10, 5, books));
        gui.setItem(42, unb2, new EnchantAction(Enchantment.DURABILITY, 2, 30, 15, books));
        gui.setItem(51, unb1, new EnchantAction(Enchantment.DURABILITY, 1, 20, 10, books));
        gui.setItem(34, thorns3, new EnchantAction(Enchantment.THORNS, 3, 25, 12, books));
        gui.setItem(43, thorns2, new EnchantAction(Enchantment.THORNS, 2, 15, 7, books));
        gui.setItem(52, thorns1, new EnchantAction(Enchantment.THORNS, 1, 10, 5, books));
      }
      else
      {
        gui.setItem(41, unb2, new EnchantAction(Enchantment.DURABILITY, 2, 30, 15, books));
        gui.setItem(50, unb1, new EnchantAction(Enchantment.DURABILITY, 1, 20, 10, books));
        gui.setItem(33, thorns3, new EnchantAction(Enchantment.THORNS, 3, 25, 12, books));
        gui.setItem(42, thorns2, new EnchantAction(Enchantment.THORNS, 2, 15, 7, books));
        gui.setItem(51, thorns1, new EnchantAction(Enchantment.THORNS, 1, 10, 5, books));
      }
      if (getEnchantTypeForItemStack(item) == EnchantType.HEAD)
      {
        gui.setItem(34, respiration3, new EnchantAction(Enchantment.OXYGEN, 3, 15, 7, books));
        gui.setItem(43, respiration2, new EnchantAction(Enchantment.OXYGEN, 2, 10, 5, books));
        gui.setItem(52, respiration1, new EnchantAction(Enchantment.OXYGEN, 1, 5, 2, books));
        gui.setItem(53, aquafin1, new EnchantAction(Enchantment.WATER_WORKER, 1, 20, 10, books));
      }
    }
    else if (getEnchantmentPartTypeForItemStack(item) == EnchantType.TOOL)
    {
      gui.setItem(10, eff5, new EnchantAction(Enchantment.DIG_SPEED, 5, 40, 20, books));
      gui.setItem(19, eff4, new EnchantAction(Enchantment.DIG_SPEED, 4, 30, 15, books));
      gui.setItem(28, eff3, new EnchantAction(Enchantment.DIG_SPEED, 3, 20, 10, books));
      gui.setItem(37, eff2, new EnchantAction(Enchantment.DIG_SPEED, 2, 10, 5, books));
      gui.setItem(46, eff1, new EnchantAction(Enchantment.DIG_SPEED, 1, 5, 2, books));
      gui.setItem(38, unb2, new EnchantAction(Enchantment.DURABILITY, 2, 30, 15, books));
      gui.setItem(47, unb1, new EnchantAction(Enchantment.DURABILITY, 1, 20, 10, books));
      gui.setItem(30, fortune3, new EnchantAction(Enchantment.LOOT_BONUS_BLOCKS, 3, 35, 17, books));
      gui.setItem(39, fortune2, new EnchantAction(Enchantment.LOOT_BONUS_BLOCKS, 2, 25, 12, books));
      gui.setItem(48, fortune1, new EnchantAction(Enchantment.LOOT_BONUS_BLOCKS, 1, 15, 7, books));
      gui.setItem(49, silk1, new EnchantAction(Enchantment.SILK_TOUCH, 1, 20, 10, books));
    }
    else if (getEnchantTypeForItemStack(item) == EnchantType.SWORD)
    {
      gui.setItem(10, sharp5, new EnchantAction(Enchantment.DAMAGE_ALL, 5, 50, 25, books));
      gui.setItem(19, sharp4, new EnchantAction(Enchantment.DAMAGE_ALL, 4, 40, 20, books));
      gui.setItem(28, sharp3, new EnchantAction(Enchantment.DAMAGE_ALL, 3, 30, 15, books));
      gui.setItem(37, sharp2, new EnchantAction(Enchantment.DAMAGE_ALL, 2, 20, 10, books));
      gui.setItem(46, sharp1, new EnchantAction(Enchantment.DAMAGE_ALL, 1, 10, 5, books));
      gui.setItem(11, smite5, new EnchantAction(Enchantment.DAMAGE_UNDEAD, 5, 30, 15, books));
      gui.setItem(20, smite4, new EnchantAction(Enchantment.DAMAGE_UNDEAD, 4, 25, 12, books));
      gui.setItem(29, smite3, new EnchantAction(Enchantment.DAMAGE_UNDEAD, 3, 15, 7, books));
      gui.setItem(38, smite2, new EnchantAction(Enchantment.DAMAGE_UNDEAD, 2, 10, 5, books));
      gui.setItem(47, smite1, new EnchantAction(Enchantment.DAMAGE_UNDEAD, 1, 5, 2, books));
      gui.setItem(12, bane5, new EnchantAction(Enchantment.DAMAGE_ARTHROPODS, 5, 30, 15, books));
      gui.setItem(21, bane4, new EnchantAction(Enchantment.DAMAGE_ARTHROPODS, 4, 25, 12, books));
      gui.setItem(30, bane3, new EnchantAction(Enchantment.DAMAGE_ARTHROPODS, 3, 20, 10, books));
      gui.setItem(39, bane2, new EnchantAction(Enchantment.DAMAGE_ARTHROPODS, 2, 15, 7, books));
      gui.setItem(48, bane1, new EnchantAction(Enchantment.DAMAGE_ARTHROPODS, 1, 10, 5, books));
      gui.setItem(31, looting3, new EnchantAction(Enchantment.LOOT_BONUS_MOBS, 3, 35, 17, books));
      gui.setItem(40, looting2, new EnchantAction(Enchantment.LOOT_BONUS_MOBS, 2, 25, 12, books));
      gui.setItem(49, looting1, new EnchantAction(Enchantment.LOOT_BONUS_MOBS, 1, 15, 7, books));
      gui.setItem(41, unb2, new EnchantAction(Enchantment.DURABILITY, 2, 30, 15, books));
      gui.setItem(50, unb1, new EnchantAction(Enchantment.DURABILITY, 1, 20, 10, books));
      gui.setItem(42, fireasp2, new EnchantAction(Enchantment.FIRE_ASPECT, 2, 40, 20, books));
      gui.setItem(51, fireasp1, new EnchantAction(Enchantment.FIRE_ASPECT, 1, 20, 10, books));
      gui.setItem(43, knock2, new EnchantAction(Enchantment.KNOCKBACK, 2, 30, 15, books));
      gui.setItem(52, knock1, new EnchantAction(Enchantment.KNOCKBACK, 1, 15, 7, books));
    }
    else
    {
      if (getEnchantTypeForItemStack(item) != EnchantType.BOW)
      {
        p.sendMessage(Util.fixColor("&cNie mozesz zaklac tego przedmiotu !"));
        return;
      }
      gui.setItem(10, power5, new EnchantAction(Enchantment.ARROW_DAMAGE, 5, 50, 25, books));
      gui.setItem(19, power4, new EnchantAction(Enchantment.ARROW_DAMAGE, 4, 40, 20, books));
      gui.setItem(28, power3, new EnchantAction(Enchantment.ARROW_DAMAGE, 3, 30, 15, books));
      gui.setItem(37, power2, new EnchantAction(Enchantment.ARROW_DAMAGE, 2, 20, 10, books));
      gui.setItem(46, power1, new EnchantAction(Enchantment.ARROW_DAMAGE, 1, 10, 5, books));
      gui.setItem(47, plomien1, new EnchantAction(Enchantment.ARROW_FIRE, 1, 10, 15, books));
      gui.setItem(39, punch2, new EnchantAction(Enchantment.ARROW_KNOCKBACK, 2, 20, 20, books));
      gui.setItem(48, punch1, new EnchantAction(Enchantment.ARROW_KNOCKBACK, 1, 10, 15, books));
      gui.setItem(40, unb2, new EnchantAction(Enchantment.DURABILITY, 2, 30, 15, books));
      gui.setItem(49, unb1, new EnchantAction(Enchantment.DURABILITY, 1, 20, 10, books));
      gui.setItem(50, infinity1, new EnchantAction(Enchantment.ARROW_INFINITE, 1, 20, 15, books));
    }
    gui.setItem(0, bookcase, null);
    gui.setItem(9, bookcase, null);
    gui.setItem(18, bookcase, null);
    gui.setItem(27, bookcase, null);
    gui.setItem(36, bookcase, null);
    gui.setItem(45, bookcase, null);
    gui.setItem(8, bookcase, null);
    gui.setItem(17, bookcase, null);
    gui.setItem(26, bookcase, null);
    gui.setItem(35, bookcase, null);
    gui.setItem(44, bookcase, null);
    gui.setItem(53, bookcase, null);
    gui.openInventory(p);
  }
  
  private static EnchantType getEnchantmentPartTypeForItemStack(ItemStack item)
  {
    switch (item.getType())
    {
    case LEATHER_HELMET: 
    case LEATHER_CHESTPLATE: 
    case LEATHER_LEGGINGS: 
    case LEATHER_BOOTS: 
    case IRON_HELMET: 
    case IRON_CHESTPLATE: 
    case IRON_LEGGINGS: 
    case IRON_BOOTS: 
    case DIAMOND_HELMET: 
    case DIAMOND_CHESTPLATE: 
    case DIAMOND_LEGGINGS: 
    case DIAMOND_BOOTS: 
    case GOLD_HELMET: 
    case GOLD_CHESTPLATE: 
    case GOLD_LEGGINGS: 
    case GOLD_BOOTS: 
      return EnchantType.ARMOR;
    case IRON_SPADE: 
    case IRON_PICKAXE: 
    case IRON_AXE: 
    case WOOD_SPADE: 
    case WOOD_PICKAXE: 
    case WOOD_AXE: 
    case STONE_SPADE: 
    case STONE_PICKAXE: 
    case STONE_AXE: 
    case DIAMOND_SPADE: 
    case DIAMOND_PICKAXE: 
    case DIAMOND_AXE: 
    case GOLD_SPADE: 
    case GOLD_PICKAXE: 
    case GOLD_AXE: 
      return EnchantType.TOOL;
    }
    return EnchantType.OTHER;
  }
  
  private static EnchantType getEnchantTypeForItemStack(ItemStack item)
  {
    switch (item.getType())
    {
    case LEATHER_HELMET: 
    case IRON_HELMET: 
    case DIAMOND_HELMET: 
    case GOLD_HELMET: 
      return EnchantType.HEAD;
    case LEATHER_CHESTPLATE: 
    case IRON_CHESTPLATE: 
    case DIAMOND_CHESTPLATE: 
    case GOLD_CHESTPLATE: 
      return EnchantType.CHEST;
    case LEATHER_LEGGINGS: 
    case IRON_LEGGINGS: 
    case DIAMOND_LEGGINGS: 
    case GOLD_LEGGINGS: 
      return EnchantType.LEGS;
    case LEATHER_BOOTS: 
    case IRON_BOOTS: 
    case DIAMOND_BOOTS: 
    case GOLD_BOOTS: 
      return EnchantType.BOOTS;
    case IRON_SWORD: 
    case WOOD_SWORD: 
    case STONE_SWORD: 
    case DIAMOND_SWORD: 
    case GOLD_SWORD: 
      return EnchantType.SWORD;
    case IRON_PICKAXE: 
    case WOOD_PICKAXE: 
    case STONE_PICKAXE: 
    case DIAMOND_PICKAXE: 
    case GOLD_PICKAXE: 
      return EnchantType.PICKAXE;
    case BOW: 
      return EnchantType.BOW;
    }
    return EnchantType.OTHER;
  }
  
  public static enum EnchantType
  {
    HEAD("HEAD", 0, "HEAD", 0, "HEAD", 0, "HEAD", 0),  CHEST("CHEST", 1, "CHEST", 1, "CHEST", 1, "CHEST", 1),  LEGS("LEGS", 2, "LEGS", 2, "LEGS", 2, "LEGS", 2),  BOOTS("BOOTS", 3, "BOOTS", 3, "BOOTS", 3, "BOOTS", 3),  SWORD("SWORD", 4, "SWORD", 4, "SWORD", 4, "SWORD", 4),  PICKAXE("PICKAXE", 5, "PICKAXE", 5, "PICKAXE", 5, "PICKAXE", 5),  BOW("BOW", 6, "BOW", 6, "BOW", 6, "BOW", 6),  OTHER("OTHER", 7, "OTHER", 7, "OTHER", 7, "OTHER", 7),  ARMOR("ARMOR", 8, "ARMOR", 8, "ARMOR", 8, "ARMOR", 8),  TOOL("TOOL", 9, "TOOL", 9, "TOOL", 9, "TOOL", 9);
    
    private EnchantType(String s4, int n4, String s3, int n3, String s2, int n2, String s, int n) {}
  }
  @EventHandler
  public void onPlayerInteractEvent(PlayerInteractEvent e)
  {
    Player p = e.getPlayer();
    if ((e.getAction() == Action.RIGHT_CLICK_BLOCK) && (e.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE))
    {
      e.setCancelled(true);
      if (e.getItem() != null)
      {
        int books = 0;
        for (Location loc : Util.getWalls(e.getClickedBlock().getLocation(), 2, 2)) {
          if (loc.getBlock().getType() == Material.BOOKSHELF) {
            books++;
          }
        }
        openEnchant(e.getPlayer(), books, e.getItem());
        return;
      }
      e.getPlayer().sendMessage(Util.fixColor(" &8» &7Aby zaklac &aprzedmiot &7wez go do reki i kliknij &aponownie &7na stol do zaklinania !"));
    }
  }
}

 

 

 

JAVA <3

 

Opublikowano

Wciskasz coś poza inventory i się wysypuje przy słaniu pakietu. Któreś setItem(50, ...)

Dodaj mój nick do posta jeśli potrzebujesz pomocy | Piszę pluginy na zlecenie | Pomagam z Linuxem

newlogo.png

Opublikowano
13 godzin temu, MarcinWieczorek napisał:

Wciskasz coś poza inventory i się wysypuje przy słaniu pakietu. Któreś setItem(50, ...)

Okej dzieki, chyba sam sobie juz dalej poradze :D

 

 

JAVA <3

 

Opublikowano

O, podjebany kod od Otka czy tam Pieprzyka XDDDD

java.lang.IndexOutOfBoundsException: Index: 50, Size: 45

Dziwna sprawa, bo powinno działać. Nie kombinowałeś nic, przy ,,konstruowaniu" menu?

Na pewno tworzy 54 sloty?

784091427630431250239.png

Regulamin sygnatur

Opublikowano
30 minut temu, Oldis napisał:

O, podjebany kod od Otka czy tam Pieprzyka XDDDD


java.lang.IndexOutOfBoundsException: Index: 50, Size: 45

Dziwna sprawa, bo powinno działać. Nie kombinowałeś nic, przy ,,konstruowaniu" menu?

Na pewno tworzy 54 sloty?

Od pieprzyka xD

http://prntscr.com/fca2g4 - nic nie kombinowalem, przepisany kod z src'a innego ;/

Jak ktos chce pomoc to moge dac cale src, bo musze to jakos naprawic, a nie wiem jak ;/
 

Cytat

Na pewno tworzy 54 sloty?

    gui = new InventoryGUI(Main.getInstance(), Util.fixColor("&aAktywne biblioteczki: &a" + books), 6);
// w InventoryGUI jest cos takiego;

  public InventoryGUI(Plugin plugin, String title, int rows)
  {
    this.inventory = Bukkit.createInventory((InventoryHolder)null, rows * 9, ChatColor.translateAlternateColorCodes('&', title));
    this.actions = new HashMap();
    Bukkit.getPluginManager().registerEvents(this, plugin);
  }

 6*9=54 ;/

 

 

JAVA <3

 

Opublikowano
2 minuty temu, Entify napisał:

Od pieprzyka xD

http://prntscr.com/fca2g4 - nic nie kombinowalem, przepisany kod z src'a innego ;/

Jak ktos chce pomoc to moge dac cale src, bo musze to jakos naprawic, a nie wiem jak ;/
 

    gui = new InventoryGUI(Main.getInstance(), Util.fixColor("&aAktywne biblioteczki: &a" + books), 6);
 

 

Dziwna sprawa, dam sobie rękę uciąć, że GUI otwiera się za małe.

Wpierdol do komentarza cały kod, który ma setItem(45+) czyli jak tam jest wyższy slot, niż 45 to // i sprawdź

784091427630431250239.png

Regulamin sygnatur

Opublikowano
3 minuty temu, Oldis napisał:

 

Dziwna sprawa, dam sobie rękę uciąć, że GUI otwiera się za małe.

Wpierdol do komentarza cały kod, który ma setItem(45+) czyli jak tam jest wyższy slot, niż 45 to // i sprawdź

nie rozumiemmm,

caly kod z inventorygui;

package me.entify.enchant.utils;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryInteractEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;

public class InventoryGUI
  implements Listener
{
  private Inventory inventory;
  private Map<Integer, IAction> actions;
  
  public InventoryGUI(Plugin plugin, String title, int rows)
  {
    this.inventory = Bukkit.createInventory((InventoryHolder)null, rows * 9, ChatColor.translateAlternateColorCodes('&', title));
    this.actions = new HashMap();
    Bukkit.getPluginManager().registerEvents(this, plugin);
  }
  
  public void setItem(int slot, ItemStack itemStack, IAction clickAction)
  {
    slot = slot > this.inventory.getSize() ? slot % this.inventory.getSize() : slot;
    this.inventory.setItem(slot, itemStack);
    this.actions.put(Integer.valueOf(slot), clickAction);
//chyba o to ci chodzilo
  }
  
  public InventoryGUI setAllItems(ItemStack[] items)
  {
    for (int i = 0; i < this.inventory.getSize(); i++) {
      this.inventory.setItem(i, items[i]);
    }
    return this;
  }
  
  public InventoryGUI setAction(int slot, IAction action)
  {
    if (action != null) {
      this.actions.put(Integer.valueOf(slot), action);
    } else {
      this.actions.remove(Integer.valueOf(slot));
    }
    return this;
  }
  
  public InventoryGUI setOpenAction(IAction action)
  {
    if (action != null) {
      this.actions.put(Integer.valueOf(-1), action);
    } else {
      this.actions.remove(Integer.valueOf(-1));
    }
    return this;
  }
  
  public ItemStack getItem(int i)
  {
    return this.inventory.getItem(i);
  }
  
  public InventoryGUI setCloseAction(IAction action)
  {
    if (action != null) {
      this.actions.put(Integer.valueOf(-2), action);
    } else {
      this.actions.remove(Integer.valueOf(-2));
    }
    return this;
  }
  
  public void openInventory(Player player)
  {
    player.openInventory(this.inventory);
  }
  
  public InventoryGUI openInventory(Player[] players)
  {
    for (Player player : players) {
      openInventory(player);
    }
    return this;
  }
  
  public InventoryGUI openInventory(Collection<? extends Player> players)
  {
    for (Player player : players) {
      openInventory(player);
    }
    return this;
  }
  
  public Inventory get()
  {
    return this.inventory;
  }
  
  @EventHandler
  public void onInventoryClick(InventoryClickEvent e)
  {
    if (e.getInventory().equals(this.inventory))
    {
      e.setCancelled(true);
      IAction action = (IAction)this.actions.get(Integer.valueOf(e.getRawSlot()));
      if (action != null) {
        action.execute((Player)e.getWhoClicked(), e.getInventory(), e.getRawSlot(), e.getInventory().getItem(e.getRawSlot()));
      } else {
        e.getWhoClicked().openInventory(e.getInventory());
      }
    }
  }
  
  @EventHandler
  public void onInventoryMoveItemEvent(InventoryMoveItemEvent e)
  {
    if (e.getDestination().equals(this.inventory)) {
      e.setCancelled(true);
    }
    if (e.getInitiator().equals(this.inventory)) {
      e.setCancelled(true);
    }
    if (this.inventory.equals(e.getSource())) {
      e.setCancelled(true);
    }
  }
  
  @EventHandler
  public void onInventoryOpen(InventoryOpenEvent e)
  {
    if (e.getInventory().equals(this.inventory))
    {
      IAction action = (IAction)this.actions.get(Integer.valueOf(-1));
      if (action != null) {
        action.execute((Player)e.getPlayer(), e.getInventory(), -1, null);
      }
    }
  }
  
  @EventHandler
  public void onInventoryClose(InventoryCloseEvent e)
  {
    if (e.getInventory().equals(this.inventory))
    {
      IAction action = (IAction)this.actions.get(Integer.valueOf(-2));
      if (action != null) {
        action.execute((Player)e.getPlayer(), e.getInventory(), -1, null);
      }
    }
  }
  
  @EventHandler
  public void onInventoryInteractEvent(InventoryInteractEvent e)
  {
    if (this.inventory.equals(e.getInventory())) {
      e.setCancelled(true);
    }
  }
  
  @EventHandler
  public void onInventoryDragEvent(InventoryDragEvent e)
  {
    if (e.getInventory().equals(this.inventory)) {
      e.setCancelled(true);
    }
  }
}

 

 

 

JAVA <3

 

Opublikowano
10 minut temu, Oskarr1239 napisał:

Daj 53 sloty

ciekawe jak, jak tam jest "rows *9", a chyba nie ma raczej liczby ktora mnozy sie przez 9 i wychodzi 53 :D

 

 

JAVA <3

 

Opublikowano
1 minutę temu, Entify napisał:

ciekawe jak, jak tam jest "rows *9", a chyba nie ma raczej liczby ktora mnozy sie przez 9 i wychodzi 53 :D

Liczy sie od 0 jak pamietam

Opublikowano
      if (action != null) {
        action.execute((Player)e.getWhoClicked(), e.getInventory(), e.getRawSlot(), e.getInventory().getItem(e.getRawSlot()));
      } else {
        e.getWhoClicked().openInventory(e.getInventory());

mam to rozumieć tak gdy IAction nie bedzie w mapie ma od nowa otworzyć inventory ?

java.lang.IndexOutOfBoundsException: Index: 50, Size: 45
        at java.util.ArrayList.rangeCheck(Unknown Source) ~[?:1.8.0_131]
        at java.util.ArrayList.get(Unknown Source) ~[?:1.8.0_131

wywala błąd związany z ArrayList której ty nigdzie nie importujesz :/ podaj pełne logi błędu, oraz linijkę gdzie sypie, jeśli korzystasz z samego api to nie powinno wywalać błędów związanych z pakietami

Opublikowano
5 minut temu, damianq20 napisał:

      if (action != null) {
        action.execute((Player)e.getWhoClicked(), e.getInventory(), e.getRawSlot(), e.getInventory().getItem(e.getRawSlot()));
      } else {
        e.getWhoClicked().openInventory(e.getInventory());

mam to rozumieć tak gdy IAction nie bedzie w mapie ma od nowa otworzyć inventory ?


java.lang.IndexOutOfBoundsException: Index: 50, Size: 45
        at java.util.ArrayList.rangeCheck(Unknown Source) ~[?:1.8.0_131]
        at java.util.ArrayList.get(Unknown Source) ~[?:1.8.0_131

wywala błąd związany z ArrayList której ty nigdzie nie importujesz :/ podaj pełne logi błędu, oraz linijkę gdzie sypie, jeśli korzystasz z samego api to nie powinno wywalać błędów związanych z pakietami

wyslac ci na pw, caly src? Pomoglbys?

 

 

JAVA <3

 

Opublikowano
1 minutę temu, damianq20 napisał:

po co mi caly kod :/ podaj logi błędu klasę która wywala oraz linijkę gdzie sypie

 

to z logow

[18:40:00] [Server thread/WARN]: Failed to handle packet for /127.0.0.1:54066
java.lang.IndexOutOfBoundsException: Index: 49, Size: 45
	at java.util.ArrayList.rangeCheck(Unknown Source) ~[?:1.8.0_131]
	at java.util.ArrayList.get(Unknown Source) ~[?:1.8.0_131]
	at net.minecraft.server.v1_7_R4.Container.getSlot(Container.java:105) ~[spigot.jar:git-PaperSpigot-43]
	at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:1516) ~[spigot.jar:git-PaperSpigot-43]
	at net.minecraft.server.v1_7_R4.PacketPlayInWindowClick.a(PacketPlayInWindowClick.java:15) ~[spigot.jar:git-PaperSpigot-43]
	at net.minecraft.server.v1_7_R4.PacketPlayInWindowClick.handle(PacketPlayInWindowClick.java:65) ~[spigot.jar:git-PaperSpigot-43]
	at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:189) ~[spigot.jar:git-PaperSpigot-43]
	at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:81) [spigot.jar:git-PaperSpigot-43]
	at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:789) [spigot.jar:git-PaperSpigot-43]
	at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:307) [spigot.jar:git-PaperSpigot-43]
	at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:638) [spigot.jar:git-PaperSpigot-43]
	at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:544) [spigot.jar:git-PaperSpigot-43]
	at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigot.jar:git-PaperSpigot-43]
[18:40:00] [Server thread/INFO]: Entify_ lost connection: Internal server error
[18:40:01] [Server thread/INFO]: Entify_ left the game.

cale;

https://pastebin.com/raw/gFJN9Qug

 

sypie sie chyba to;

  public InventoryGUI(Plugin plugin, String title, int rows)
  {
    this.inventory = Bukkit.createInventory((InventoryHolder)null, rows * 9, ChatColor.translateAlternateColorCodes('&', title));
//rows = 6
    this.actions = new HashMap();
    Bukkit.getPluginManager().registerEvents(this, plugin);
  }
  
  public void setItem(int slot, ItemStack itemStack, IAction clickAction)
  {
    slot = slot > this.inventory.getSize() ? slot % this.inventory.getSize() : slot;
    this.inventory.setItem(slot, itemStack);
    this.actions.put(Integer.valueOf(slot), clickAction);
  }

cale inventorygui;

package me.entify.enchant.utils;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryInteractEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;

public class InventoryGUI
  implements Listener
{
  private Inventory inventory;
  private Map<Integer, IAction> actions;
  
  public InventoryGUI(Plugin plugin, String title, int rows)
  {
    this.inventory = Bukkit.createInventory((InventoryHolder)null, rows * 9, ChatColor.translateAlternateColorCodes('&', title));
    this.actions = new HashMap();
    Bukkit.getPluginManager().registerEvents(this, plugin);
  }
  
  public void setItem(int slot, ItemStack itemStack, IAction clickAction)
  {
    slot = slot > this.inventory.getSize() ? slot % this.inventory.getSize() : slot;
    this.inventory.setItem(slot, itemStack);
    this.actions.put(Integer.valueOf(slot), clickAction);
  }
  
  public InventoryGUI setAllItems(ItemStack[] items)
  {
    for (int i = 0; i < this.inventory.getSize(); i++) {
      this.inventory.setItem(i, items[i]);
    }
    return this;
  }
  
  public InventoryGUI setAction(int slot, IAction action)
  {
    if (action != null) {
      this.actions.put(Integer.valueOf(slot), action);
    } else {
      this.actions.remove(Integer.valueOf(slot));
    }
    return this;
  }
  
  public InventoryGUI setOpenAction(IAction action)
  {
    if (action != null) {
      this.actions.put(Integer.valueOf(-1), action);
    } else {
      this.actions.remove(Integer.valueOf(-1));
    }
    return this;
  }
  
  public ItemStack getItem(int i)
  {
    return this.inventory.getItem(i);
  }
  
  public InventoryGUI setCloseAction(IAction action)
  {
    if (action != null) {
      this.actions.put(Integer.valueOf(-2), action);
    } else {
      this.actions.remove(Integer.valueOf(-2));
    }
    return this;
  }
  
  public void openInventory(Player player)
  {
    player.openInventory(this.inventory);
  }
  
  public InventoryGUI openInventory(Player[] players)
  {
    for (Player player : players) {
      openInventory(player);
    }
    return this;
  }
  
  public InventoryGUI openInventory(Collection<? extends Player> players)
  {
    for (Player player : players) {
      openInventory(player);
    }
    return this;
  }
  
  public Inventory get()
  {
    return this.inventory;
  }
  
  @EventHandler
  public void onInventoryClick(InventoryClickEvent e)
  {
    if (e.getInventory().equals(this.inventory))
    {
      e.setCancelled(true);
      IAction action = (IAction)this.actions.get(Integer.valueOf(e.getRawSlot()));
      if (action != null) {
        action.execute((Player)e.getWhoClicked(), e.getInventory(), e.getRawSlot(), e.getInventory().getItem(e.getRawSlot()));
      } else {
        e.getWhoClicked().openInventory(e.getInventory());
      }
    }
  }
  
  @EventHandler
  public void onInventoryMoveItemEvent(InventoryMoveItemEvent e)
  {
    if (e.getDestination().equals(this.inventory)) {
      e.setCancelled(true);
    }
    if (e.getInitiator().equals(this.inventory)) {
      e.setCancelled(true);
    }
    if (this.inventory.equals(e.getSource())) {
      e.setCancelled(true);
    }
  }
  
  @EventHandler
  public void onInventoryOpen(InventoryOpenEvent e)
  {
    if (e.getInventory().equals(this.inventory))
    {
      IAction action = (IAction)this.actions.get(Integer.valueOf(-1));
      if (action != null) {
        action.execute((Player)e.getPlayer(), e.getInventory(), -1, null);
      }
    }
  }
  
  @EventHandler
  public void onInventoryClose(InventoryCloseEvent e)
  {
    if (e.getInventory().equals(this.inventory))
    {
      IAction action = (IAction)this.actions.get(Integer.valueOf(-2));
      if (action != null) {
        action.execute((Player)e.getPlayer(), e.getInventory(), -1, null);
      }
    }
  }
  
  @EventHandler
  public void onInventoryInteractEvent(InventoryInteractEvent e)
  {
    if (this.inventory.equals(e.getInventory())) {
      e.setCancelled(true);
    }
  }
  
  @EventHandler
  public void onInventoryDragEvent(InventoryDragEvent e)
  {
    if (e.getInventory().equals(this.inventory)) {
      e.setCancelled(true);
    }
  }
}

 

 

 

JAVA <3

 

Opublikowano
14 minut temu, damianq20 napisał:

spróbuj debugować, ale stawiam na błąd w nms .. spróbuj inną wersją

gdybyś podał złą liczbę slotów to by sypało illegalargumentException

https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Bukkit.html#createInventory-org.bukkit.inventory.InventoryHolder-int-java.lang.String-

inną wersją czyli? ;/

 

 

JAVA <3

 

Opublikowano

inna wersje nie wiem jaką masz jedynie że

at net.minecraft.server.v1_7_R4

wgraj  najnowszą tego 1.7 lub 1.8 1.8 powinno dzialac 

Opublikowano

Ale on przecież nie używa importów NMSa. Weź nie zmyślaj chłopie. Jakby to się miało z silnikiem pieprzyć to gwarantuję, że by się sypało przy każdej możliwej okazji. A w inventory to się od dawna pewnie nic nie zmieniło.

P.S. R4 to najnowszy 1.7.

Dodaj mój nick do posta jeśli potrzebujesz pomocy | Piszę pluginy na zlecenie | Pomagam z Linuxem

newlogo.png

Opublikowano

tia ale jak pokazuje całe logi to to jest jedyne co mi przychodzi na myśl. wywala mu arrayList której nigdzie nie ma :/ ciekawe gdzie :?

Opublikowano

Mam najnowszego paperspigota,

// jak chcecie moge podeslac cale src

 

 

JAVA <3

 

Opublikowano
2 godziny temu, damianq20 napisał:

tia ale jak pokazuje całe logi to to jest jedyne co mi przychodzi na myśl. wywala mu arrayList której nigdzie nie ma :/ ciekawe gdzie :?

Przepierdala zakres....

 

@Topic

 

Jezu i dlatego takie osoby jak Ty, nie powinny brać się za programowanie, gdy nie mają pierdolonych PODSTAW nauczonych.

Byłem kurwa tak samo uparty jak WY (Mowa tutaj o wszystkich mistrzach podpierdalania kodu) i zamiast sam coś napisać to kopiowałem i na omacku próbowałem przerobić.

Powiedziałem Ci wyraźnie, wypierdole setItem(45+) i otwórz menu i sprawdź, czy na pewno się dobrze stworzyło....

784091427630431250239.png

Regulamin sygnatur

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...