Guest User

Untitled

a guest
Jun 2nd, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. package me.leo.vanish;
  2.  
  3. import java.io.PrintStream;
  4. import java.util.ArrayList;
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11.  
  12. import br.com.devpaulo.legendchat.api.events.ChatMessageEvent;
  13.  
  14. public class Main
  15. extends JavaPlugin
  16. {
  17. public ArrayList<Player> vanish = new ArrayList();
  18. public static Main plugin;
  19.  
  20. public void onEnable() {
  21. Bukkit.getPluginManager().registerEvents(new VanishEvents(), this);
  22. plugin = this;
  23. }
  24.  
  25. public void onDisable() {
  26. }
  27.  
  28. public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
  29. {
  30. if (command.getName().contains("vanish"))
  31. {
  32. if (!(sender instanceof Player))
  33. {
  34. sender.sendMessage("§cVocê precisa ser um jogador");
  35. return true;
  36. }
  37. Player player = (Player)sender;
  38. if (!player.hasPermission("obycraft.vanish"))
  39. {
  40. player.sendMessage("§cVocê não possui permissão para esse comando!");
  41. return true;
  42. }
  43. if (args.length > 0)
  44. {
  45. if (args[0].contains("list"))
  46. {
  47. player.sendMessage("§aJogadores em modo invisível: ");
  48. for (Player all : this.vanish) {
  49. player.sendMessage("§8" + all.getName() + "\n");
  50. }
  51. }
  52. return true;
  53. }
  54. if (this.vanish.contains(player))
  55. {
  56. for (Player all : Bukkit.getOnlinePlayers())
  57. {
  58. all.showPlayer(player);
  59. if (all.hasPermission("obycraft.vanish")) {
  60. all.sendMessage("§d§l[VANISH] " + player.getName() + " §asaiu do modo invisível!");
  61. }
  62. }
  63. this.vanish.remove(player);
  64. return true;
  65. }
  66. for (Player all : Bukkit.getOnlinePlayers()) {
  67. if (!all.hasPermission("obycraft.vanish")) {
  68. all.hidePlayer(player);
  69. } else {
  70. all.sendMessage("§d§l[VANISH] " + player.getName() + " §aentrou no modo invisível");
  71. }
  72. }
  73. this.vanish.add(player);
  74.  
  75. return true;
  76. }
  77. return true;
  78. }
  79. @EventHandler
  80. public void onChat(ChatMessageEvent e) {
  81. if (e.getChannel().getName().equals("local")) { // Verifica se foi no chat local
  82. for (String player : vanish) {
  83. if (e.getRecipients().contains(Bukkit.getPlayer(player)) {
  84. e.getRecipients().remove(Bukkit.getPlayer(player());
  85. Bukkit.getPlayer(player).sendMessage(e.getSender().getName() + ": " + e.getMessage());
  86. }
  87. }
  88. }
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment