Advertisement
Guest User

Untitled

a guest
May 21st, 2015
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. package me.TheRealHarut.ServerSelector;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.Material;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.event.EventHandler;
  8. import org.bukkit.event.Listener;
  9. import org.bukkit.event.block.Action;
  10. import org.bukkit.event.player.PlayerInteractEvent;
  11. import org.bukkit.inventory.Inventory;
  12. import org.bukkit.inventory.ItemStack;
  13. import org.bukkit.plugin.java.JavaPlugin;
  14.  
  15. public class Main extends JavaPlugin implements Listener {
  16.  
  17. public Inventory inv;
  18. public Player p;
  19.  
  20. @Override
  21. public void onEnable(){
  22. Bukkit.getPluginManager().registerEvents(this, this);
  23. }
  24.  
  25. @EventHandler
  26. public void onInteract(PlayerInteractEvent e){
  27. Player p = e.getPlayer();
  28. Action a = e.getAction();
  29. if (a.equals(Action.RIGHT_CLICK_AIR) || a.equals(Action.RIGHT_CLICK_BLOCK)){
  30. if (p.getItemInHand().getType().equals(Material.COMPASS)){
  31. p.openInventory(inv);
  32. }
  33. }
  34. }
  35.  
  36. public class ClickActionCommand implements IAction
  37. {
  38. private String command;
  39.  
  40. public ClickActionCommand(String command)
  41. {
  42. this.command = command;
  43. }
  44.  
  45. @Override
  46. public void execute(Player player, Inventory inventory, int slot, ItemStack itemStack)
  47. {
  48. Bukkit.dispatchCommand(player, command);
  49. player.closeInventory();
  50. }
  51. }
  52.  
  53.  
  54.  
  55.  
  56. public class OpenAction implements IAction
  57. {
  58. private String command;
  59.  
  60. public OpenAction(String command)
  61. {
  62. this.command = command;
  63. }
  64.  
  65. @Override
  66. public void execute(Player player, Inventory inventory, int slot, ItemStack itemStack)
  67. {
  68. }
  69. }
  70.  
  71.  
  72. {
  73. }
  74. {
  75.  
  76.  
  77.  
  78. new InventoryGUI(plugin, "&b&lServer Selector" , 9) //Create the Inventory GUI with title and # of rows
  79. .setItem(0, new ItemStack(Material.DIAMOND_AXE), new ClickActionCommand("kill")) //Add an item
  80. .setItem(1, new ItemStack(Material.BEACON), new ClickActionCommand("spawn")) //^
  81. .setOpenAction(new OpenAction("")) // Add an action for when it's opened
  82. .openInventory(Bukkit.getPlayer(""));{
  83. //Open the inventory for myself
  84. }
  85.  
  86.  
  87.  
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement