public class Main extends JavaPlugin implements Listener{
public static Boolean kity;
@Override
public void onEnable(){
Bukkit.getServer().getPluginManager().registerEvents(this, this);
System.out.println("Wlaczanie...");
Main.kity = true;
}
@Override
public void onDisable(){
System.out.println("Wylaczanie...");
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player p = (Player) sender;
if(cmd.getName().equalsIgnoreCase("zestawy")){
if(args.length >= 0){
if(args[0] == null){
createMenu(p);
}
if(args[0].equalsIgnoreCase("przelacz")){
if(p.hasPermission("kity.przelacz")){
if(kity){
kity = false;
p.sendMessage("§cWylaczyles kity");
}else{
kity = true;
p.sendMessage("§cWlaczyles kity");
}
}
}
}
}
return false;
}
public void createMenu(Player player){
Inventory inv = Bukkit.getServer().createInventory(null,9,"§6§lKity");
ItemStack gracz = new ItemStack(Material.STONE_SWORD, 1);
ItemMeta graczim = gracz.getItemMeta();
ArrayList<String> graczlore = new ArrayList<String>();
graczlore.add("§8» §7Kliknij aby otrzymac zestaw gracz");
graczlore.add(" §a§lKAZDY MOZE OTRZYMAC ZESTAW GRACZ");
graczim.setDisplayName("§7Zestaw §8Gracz");
graczim.setLore(graczlore);
gracz.setItemMeta(graczim);
ItemStack vip = new ItemStack(Material.GOLD_SWORD, 1);
ItemMeta vipim = vip.getItemMeta();
ArrayList<String> viplore = new ArrayList<String>();
viplore.add("§8» §7Kliknij aby otrzymac zestaw §6vip");
viplore.add(" §a§lKAZDY VIP MOZE OTRZYMAC TEN ZESTAW");
vipim.setDisplayName("§7Zestaw §6VIP");
vipim.setLore(viplore);
vip.setItemMeta(vipim);
ItemStack svip = new ItemStack(Material.DIAMOND_SWORD, 1);
ItemMeta svipim = svip.getItemMeta();
ArrayList<String> sviplore = new ArrayList<String>();
sviplore.add("§8» §7Kliknij aby otrzymac zestaw §9s§6vip");
sviplore.add(" §a§lKAZDY SVIP MOZE OTRZYMAC TEN ZESTAW");
svipim.setDisplayName("§7Zestaw §9S§6VIP");
svipim.setLore(sviplore);
svip.setItemMeta(svipim);
ItemStack yt = new ItemStack(Material.IRON_SWORD, 1);
ItemMeta ytim = yt.getItemMeta();
ArrayList<String> ytlore = new ArrayList<String>();
ytlore.add("§8» §7Kliknij aby otrzymac zestaw §fY§4T");
ytlore.add(" §a§lKAZDY YOUTUBER MOZE OTRZYMAC TEN ZESTAW");
ytim.setDisplayName("§7Zestaw §fY§4T");
ytim.setLore(ytlore);
yt.setItemMeta(ytim);
ItemStack glass = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
ItemMeta glassim = glass.getItemMeta();
glassim.setDisplayName("§0#");
glass.setItemMeta(glassim);
inv.setItem(0, gracz);
inv.setItem(1, vip);
inv.setItem(2, svip);
inv.setItem(3, yt);
inv.setItem(4, glass);
inv.setItem(5, glass);
inv.setItem(6, glass);
inv.setItem(7, glass);
inv.setItem(8, glass);
player.openInventory(inv);
}
@EventHandler
public void onInvClick(InventoryClickEvent e){
Player p = (Player) e.getWhoClicked();
if(e.getInventory().getName() != "§6§lKity"){
return;
}
if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§7Zestaw §8Gracz")){
e.setCancelled(true);
p.closeInventory();
p.performCommand("kit gracz");
}
if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§0#")){
e.setCancelled(true);
}
if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§7Zestaw §6VIP")){
e.setCancelled(true);
if(kity){
p.closeInventory();
p.performCommand("kit vip");
}else{
p.closeInventory();
p.sendMessage("§cZestawy sa wylaczone !");
}
}
if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§7Zestaw §9S§6VIP")){
e.setCancelled(true);
if(kity){
p.closeInventory();
p.performCommand("kit svip");
}else{
p.closeInventory();
p.sendMessage("§cZestawy sa wylaczone !");
}
}
if(e.getCurrentItem().getItemMeta().getDisplayName().contains("§7Zestaw §fY§4T")){
e.setCancelled(true);
if(kity){
p.closeInventory();
p.performCommand("kit yt");
}else{
p.closeInventory();
p.sendMessage("§cZestawy sa wylaczone !");
}
}
}
}
Logi:
[18:55:38 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'zestawy' in plugin VHCKity v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_151]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_151]
at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at pl.hotangel2k17.kits.Main.onCommand(Main.java:40) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
... 15 more
Pytanie
kerpson 551
Mam taki kod. On nie dziala, bledy z konsoli.
Logi:
[18:55:38 ERROR]: null org.bukkit.command.CommandException: Unhandled exception executing command 'zestawy' in plugin VHCKity v1.0 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_151] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_151] at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151] Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 at pl.hotangel2k17.kits.Main.onCommand(Main.java:40) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] ... 15 moreOdnośnik do komentarza
https://skript.pl/temat/26044-czemu-to-nie-dziala/Udostępnij na innych stronach
1 odpowiedź na to pytanie
Rekomendowane odpowiedzi