I have 2 questions How to add a command from another plugin to my plugin? And If you click on the item in your menu that it uses a bungee command (My english is not good)
1. You can simply execute the command from the other plugin when your plugin's command is run. 2. Use PlayerInteractEvent to execute the requirement bungee command.
It means when you do your command (like /test) You can execute another command (like /test1) with player.performCommand("") Sorry if I typed it wrong. Im on phone
Thanks! But now where do it need to put the first one? Code (Text): package inventory; import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; public class InventoryClick implements Listener { @EventHandler public void onInventoryClick(InventoryClickEvent event) { Inventory inv = event.getInventory(); if(!(inv.getTitle().equals("Server Travel"))) return; if(!(event.getWhoClicked() instanceof Player)) return; Player player =(Player) event.getWhoClicked(); ItemStack item = event.getCurrentItem(); event.setCancelled(true); if(item.getType() == Material.GOLD_BLOCK) { player.teleport(player.getWorld().getSpawnLocation()); player.sendMessage(ChatColor.GREEN + "Teleported to hub!"); event.setCancelled(true); player.closeInventory(); player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 1); } } } And the teleport thing is gonna be removed and the bungee thing is gonna be added
Sorry, but I meant the second and i have this now (I'm very noob) Code (Text): package inventory; 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.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; public class InventoryClick implements Listener { @EventHandler public void onInventoryClick(InventoryClickEvent event) { Inventory inv = event.getInventory(); if(!(inv.getTitle().equals("Server Travel"))) return; if(!(event.getWhoClicked() instanceof Player)) return; Player player =(Player) event.getWhoClicked(); ItemStack item = event.getCurrentItem(); event.setCancelled(true); } @EventHandler public void onPlayerInteract(PlayerInteractEvent e) { Player player = e.getPlayer(); { } event.setCancelled(true); player.closeInventory(); { } } } I get an error with this event.setCancelled(true); the last one and where do i need to put the bungee command? I don't understand xd
What is the error? You should run the bungee command once all conditions have been met; In this case, you can put it after event.setCancelled(true);
Also possible, i most of all use player.chat because its shorter to write You can also use Bukkit.getServer().dispatchCommand(Player, "YourCommand"):