Lexepi

Untitled

Apr 6th, 2017
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. package fr.lexepi.chat.listeners;
  2.  
  3. import org.bukkit.Material;
  4. import org.bukkit.entity.Player;
  5. import org.bukkit.event.EventHandler;
  6. import org.bukkit.event.Listener;
  7. import org.bukkit.event.inventory.InventoryClickEvent;
  8.  
  9. import fr.lexepi.chat.Chat;
  10. import fr.lexepi.chat.CurrentChat;
  11.  
  12. public class InventoryInteract implements Listener{
  13.  
  14. private Chat main;
  15.  
  16. public InventoryInteract(Chat plugin){
  17. this.main = plugin;
  18. }
  19.  
  20. String prefix = "§4§l[§cChat§4§l]";
  21.  
  22. @EventHandler
  23. public void Interact(InventoryClickEvent e){
  24. Player p = (Player) e.getWhoClicked();
  25. if(p.getOpenInventory().getTitle().equalsIgnoreCase("§4§lOptions")){
  26. if(e.getCurrentItem().getType() == Material.EMERALD_BLOCK){
  27. if(e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§a§lChat on")){
  28. e.setCancelled(true);
  29.  
  30. if(main.getState(CurrentChat.ACTIVATE)){
  31. p.sendMessage(prefix+" §cLe chat est déjà activé !");
  32. }
  33.  
  34. if(main.getState(CurrentChat.DESACTIVATE)){
  35. main.setState(CurrentChat.ACTIVATE);
  36. p.sendMessage(prefix+" §aVous venez de réactiver le chat !");
  37. }
  38. }
  39.  
  40.  
  41. }else if(e.getCurrentItem().getType() == Material.REDSTONE_BLOCK){
  42. if(e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§c§lChat off")){
  43. e.setCancelled(true);
  44.  
  45. if(main.getState(CurrentChat.DESACTIVATE)){
  46. p.sendMessage(prefix+" §cLe chat est déjà désactivé !");
  47. }
  48.  
  49. if(main.getState(CurrentChat.ACTIVATE)){
  50. main.setState(CurrentChat.DESACTIVATE);
  51. p.sendMessage(prefix+" §aVous venez de désactivé le chat !");
  52. }
  53. }
  54. }
  55. }
  56.  
  57. }
  58.  
  59. }
Add Comment
Please, Sign In to add comment