W
wFBP4M8GY4yz_rHGRznhrpid
Unregistriert
Ja moin, ich wollte heute ein Bukkit Plugin coden in dem mann gerade in einen Inventory ist wo mann auf Information klickt, und dann sich ein neues Inventar öffnet.
Aber den wurde mir eine Exception geworfen? Aber ich kenne mich in dem Bereich "Exception" nicht aus.
Die Klasse:
Mein Error:
Aber den wurde mir eine Exception geworfen? Aber ich kenne mich in dem Bereich "Exception" nicht aus.
Die Klasse:
Code:
package net.!!!WERBUNG!!!;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
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.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
public class compass implements Listener{
private static Main plugin;
public compass(Main Main)
{
plugin = Main;
}
@EventHandler
public void onInteract(PlayerInteractEvent e){
if ((((e.getAction() == Action.RIGHT_CLICK_BLOCK ? 1 : 0) | (e.getAction() == Action.RIGHT_CLICK_AIR ? 1 : 0)) != 0) &&
(e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§9§oNavigator")))
{
final Player p = e.getPlayer();
e.setCancelled(true);
final Inventory inv = Bukkit.createInventory(null, 27, "§9§oNavigation");
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(5, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 6L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(6, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 7L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(7, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 8L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(8, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 9L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(17, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 10L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(26, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 11L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(25, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 12L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(24, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 13L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(23, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 14L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(22, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 15L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(21, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 16L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(20, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 17L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(19, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 18L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(18, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 19L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(9, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 20L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(0, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 22L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(1, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 23L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(2, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 24L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
inv.setItem(3, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 25L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
inv.setItem(4, Item.IDStack("§9XYZ", 160, "", 1, 11));
}
}, 26L);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
public void run()
{
p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
inv.setItem(11, Item.IDStack("§9Hoster", 331, "§7Bekommen einen Link zu unserem §9Hoster", 1, 0));
inv.setItem(13, Item.IDStack("§9Spawn", 260, "§7Der schnellste Weg um zum §9Anfang §7zukommen", 1, 0));
inv.setItem(15, Item.IDStack("§9Information", 339, "§7Alle §9Information §7über diesen Server", 1, 0));
}
}, 26L);
p.openInventory(inv);
}
}
@EventHandler
public void onClick(InventoryClickEvent e){
Player p = (Player)e.getWhoClicked();
ItemStack ic = e.getCurrentItem();
//Hoster
if (ic.getItemMeta().getDisplayName().equalsIgnoreCase("§9Hoster"))
{
p.closeInventory();
p.sendMessage("§7[§9XYZ§7] §7Hosted by §9!!!BLOCKED WERBUNG!!!");
p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1.0F, 1.0F);
}
//Spawn
if (ic.getItemMeta().getDisplayName().equalsIgnoreCase("§9Spawn"))
{
p.closeInventory();
p.sendMessage("§7[§9XYZ§7] §7Du bist nun am §9Spawn");
p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1.0F, 1.0F);
//Information
if (ic.getItemMeta().getDisplayName().equalsIgnoreCase("§9Information"))
{
Inventory informationinv = Bukkit.createInventory(null, 27, "§9Information");
p.sendMessage("Hallo");
p.openInventory(informationinv);
}
}
}
}
Mein Error:
Code:
[07:24:16] [Server thread/INFO]: There are 1/30 players online:
[07:24:16] [Server thread/INFO]: ByteVentix
[07:24:27] [Server thread/ERROR]: Could not pass event InventoryClickEvent to !!!WERBUNG!!!Lobby v1.0
org.bukkit.event.EventException
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:305) ~[spigot-1.8.jar:git-Spigot-8a983f9-e81edfc]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.jar:git-Spigot-8a983f9-e81edfc]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.8.jar:git-Spigot-8a983f9-e81edfc]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.8.jar:git-Spigot-8a983f9-e81edfc]
at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:1588) [spigot-1.8.jar:git-Spigot-8a983f9-e81edfc]
at net.minecraft.server.v1_8_R1.PacketPlayInWindowClick.a(SourceFile:31) [spigot-1.8.jar:git-Spigot-8a983f9-e81edfc]
at net.minecraft.server.v1_8_R1.PacketPlayInWindowClick.a(SourceFile:9) [spigot-1.8.jar:git-Spigot-8a983f9-e81edfc]
at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigot-1.8.jar:git-Spigot-8a983f9-e81edfc]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_121]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_121]
at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:696) [spigot-1.8.jar:git-Spigot-8a983f9-e81edfc]
at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot-1.8.jar:git-Spigot-8a983f9-e81edfc]
at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:634) [spigot-1.8.jar:git-Spigot-8a983f9-e81edfc]
at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:537) [spigot-1.8.jar:git-Spigot-8a983f9-e81edfc]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
Caused by: java.lang.NullPointerException
at net.treudler.compass.onClick(compass.java:218) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ~[spigot-1.8.jar:git-Spigot-8a983f9-e81edfc]