Advertisement
Guest User

Untitled

a guest
May 20th, 2015
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 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.inventory.InventoryClickEvent;
  11. import org.bukkit.event.player.PlayerInteractEvent;
  12. import org.bukkit.inventory.Inventory;
  13. import org.bukkit.inventory.ItemStack;
  14. import org.bukkit.plugin.java.JavaPlugin;
  15.  
  16. public class Main extends JavaPlugin implements Listener {
  17.  
  18. public Inventory inv;
  19. public Player p;
  20.  
  21. @Override
  22. public void onEnable(){
  23. inv = Bukkit.createInventory(null ,9 , ChatColor.AQUA + "Server Selector");
  24. inv.addItem(new ItemStack(Material.GOLDEN_APPLE));
  25. Bukkit.getPluginManager().registerEvents(this, this);
  26. }
  27.  
  28. @EventHandler
  29. public void onInteract(PlayerInteractEvent e){
  30. Player p = e.getPlayer();
  31. Action a = e.getAction();
  32. if (a.equals(Action.RIGHT_CLICK_AIR) || a.equals(Action.RIGHT_CLICK_BLOCK)){
  33. if (p.getItemInHand().getType().equals(Material.COMPASS)){
  34. p.openInventory(inv);
  35. }
  36. }
  37. }
  38.  
  39. public class ClickActionCommand implements IAction
  40. {
  41. private String command;
  42.  
  43. public ClickActionCommand(String command)
  44. {
  45. this.command = command;
  46. }
  47.  
  48. @Override
  49. public void execute(Player player, Inventory inventory, int slot, ItemStack itemStack)
  50. {
  51. Bukkit.dispatchCommand(player, command);
  52. player.closeInventory();
  53. }
  54. }
  55.  
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement