Jump to content

Mal wieder Probleme mit dem Teleporterplugin.


Uzade
 Share

Recommended Posts

Moin,

ich hoffe mir kann wieder jemand helfen.
meine Intention:
man rechts-klickt den Kompass und kommt in ein Inventar in dem man zwischen Shop und Teleporter wählen kann.
Den Teleporter hatt ich vorher schon programmiert, da dürfte nicht viel falsch sein.
Im Shop soll erstmal noch nichts passieren.

Wenn ich rechts-klicke kommt nur ne Fehlermeldung.

S.h. unten die genannte Fehlermeldung + den Code (Ich weiß, dass es viel ist)

Ich hoffe jemand kann mir helfen.

[16:00:51 ERROR]: Could not pass event PlayerInteractEvent to Uzadesmod v2.4.2
org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:228) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PlayerInteractManager.interact(PlayerInteractManager.java:463) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:759) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:52) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:1) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_251]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_251]
        at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-db6de12-18fbb24]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_251]
Caused by: java.lang.ArrayIndexOutOfBoundsException: 9
        at org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCustom$MinecraftInventory.setItem(CraftInventoryCustom.java:105) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory.setItem(CraftInventory.java:79) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
        at de.uzade.main.Navigator.openMainGUI(Navigator.java:22) ~[?:?]
        at de.uzade.main.Navigator.handleNavigatorOpener(Navigator.java:53) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_251]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_251]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_251]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_251]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
        ... 17 more
package de.uzade.main;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
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;

public class Navigator implements Listener{
	
	public void openMainGUI(Player player) {
		Inventory invent = Bukkit.createInventory(player, 9*1, "Atomix-Tool");
		invent.setItem(2, new ItemBuilder(Material.GOLD_BLOCK).setName("Shop").setLore("buy different Chests for ingame-money").build());
		invent.setItem(5, new ItemBuilder(Material.COMPASS).setName("Teleporter").setLore("Teleport to different Planets").build());
		invent.setItem(9, new ItemBuilder(Material.ARROW).setName("Back").setLore("closes the Atomix-Tool").build());
		player.openInventory(invent);
	}

	public void openShopGUI(Player player) {
		Inventory invent = Bukkit.createInventory(player, 9*1, "Shop");
		invent.setItem(2, new ItemBuilder(Material.CHEST).setName("Lvl 1-chest").setLore("normal chest with normal sh#t").build());
		invent.setItem(5, new ItemBuilder(Material.ENDER_CHEST).setName("Lvl 2-chest").setLore("epical Loot for epical Progamers!").build());
		invent.setItem(9, new ItemBuilder(Material.ARROW).setName("Back").setLore("Go back to main page").build());
		player.openInventory(invent);
	}
	
	public void openTeleGUI(Player player) {
		Inventory invent = Bukkit.createInventory(player, 9*1, "Teleporter");
		invent.setItem(0, new ItemBuilder(Material.GOLDEN_APPLE).setName("Lobbyapfel").setLore("Hier gehts zur Lobby!").build());
		invent.setItem(2, new ItemBuilder(Material.BED).setName("Bedwars").setLore("Hier klicken für Bedwars").build());
		invent.setItem(3, new ItemBuilder(Material.IRON_PICKAXE).setName("Masterbuilders").setLore("Teleports you to masterbuilders").build());
		invent.setItem(4, new ItemBuilder(Material.WATER_BUCKET).setName("Dropper").setLore("Teleports you to dropper").build());
		invent.setItem(5, new ItemBuilder(Material.BOW).setName("Battle Royale").setLore("Teleports you to Battle Royale").build());
		invent.setItem(9, new ItemBuilder(Material.ARROW).setName("Back").setLore("Go back to main page").build());
		player.openInventory(invent);
	}
	
	@EventHandler
	public void handleNavigatorOpener(PlayerInteractEvent event) {
		Player player = event.getPlayer();
		if(player.getItemInHand() == null || player.getItemInHand().getType() == Material.AIR) return;
		if(event.getItem().getType() != Material.COMPASS) return;
		if(event.getItem().getItemMeta() == null) return;
		if(event.getItem().getItemMeta().getDisplayName().equals("§6Teleporter")) {
			if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
				openMainGUI(event.getPlayer());
			}
		}
		
	}
	@EventHandler	
	public void handleNavigatorGUIClick(InventoryClickEvent event) {
		if(!(event.getWhoClicked() instanceof Player)) return;
		Player player = (Player) event.getWhoClicked();
		if(event.getClickedInventory().getTitle() == null) return;
		if(event.getClickedInventory().getTitle().equals("Atomix-Tool")) {
			if(event.getCurrentItem() == null) return;
			switch(event.getCurrentItem().getType()) {
				
			case GOLD_BLOCK:
				player.closeInventory();
				openShopGUI(player);
				break;
				
			case COMPASS:
				player.closeInventory();
				openTeleGUI(player);
				break;
				
			case ARROW:
				player.closeInventory();
				break;
				
			default:
				break;
			}
			return;
		}
		
		else if(event.getClickedInventory().getTitle().equals("Teleporter")) {
			
			FileConfiguration config = Main.getPlugin().getConfig();
			String i = "0";
			
			if(event.getCurrentItem() == null) return;
			switch(event.getCurrentItem().getType()) {
				
			case GOLDEN_APPLE:
				i = "Spawn";
				break;
			
			case BED:
				i = "1";
				break;
			
			case IRON_PICKAXE:
				i = "2";
				break;
				
			case WATER_BUCKET:
				i = "3";
				break;
				
			case BOW:
				i = "4";
				break;
				
			case ARROW:
				player.closeInventory();
				openMainGUI(player);
				
			default:
				break;
			
			}
			
			World world = Bukkit.getWorld(config.getString(i + ".World"));
			double x = config.getDouble(i + ".X");
			double y = config.getDouble(i + ".Y");
			double z = config.getDouble(i + ".Z");
			float yaw = (float) config.getDouble(i + ".Yaw");
			float pitch = (float) config.getDouble(i + ".Pitch");
			
			Location loc = new Location(world, x, y, z, yaw, pitch);
			
			player.teleport(loc);
			return;
		}
		else if(event.getClickedInventory().getTitle().equals("Shop")) {
			return;
		}
	}
	
}

 

Link to comment
Share on other sites

invent.setItem(9, new ItemBuilder(Material.ARROW).setName("Back").setLore("closes the Atomix-Tool").build());
		

Arrays beginnen bei 0, nicht bei 1. Du erstellst ein Inventar mit 9 Slots => 1. Slot ist Index 0 und 9. Slot ist Index 8.

Link to comment
Share on other sites

Aber jetzt ist immer noch ein anderes Problem, Wenn ich ins 2. Inventar wechsle habe ich direkt ein Item in der Hand und kann die Items aus dem Inventar ziehen, ohne das irgendwas passiert wenn ich sie anklicke.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...
B
B