Advertisement
DecisionsYT

Untitled

May 12th, 2016
71
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None
  1. package ChatFilter;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandExecutor;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.event.player.AsyncPlayerChatEvent;
  13. import org.bukkit.event.player.PlayerCommandPreprocessEvent;
  14.  
  15. import me.DecisionsYT.Main;
  16.  
  17. public class CmdSpy implements Listener, CommandExecutor {
  18.  
  19. Main plugin;
  20.  
  21. public CmdSpy(Main passedPlugin) {
  22. this.plugin = passedPlugin;
  23. }
  24.  
  25. List<Player> spyActivated = new ArrayList();
  26.  
  27. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  28.  
  29. Player player = (Player)sender;
  30.  
  31. @EventHandler
  32. public void commandEvent(PlayerCommandPreprocessEvent e) {
  33. for (Player staff : this.spyActivated)
  34. if (!staff.equals(e.getPlayer())) staff.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("CmdSpy-Format").replace("{player}", e.getPlayer().getName().replace("{command}", e.getMessage()))));
  35. }
  36.  
  37.  
  38.  
  39.  
  40.  
  41. if (args.length == 0) {
  42. sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("CmdSpy-Usage")));
  43. }
  44.  
  45. if (args.length == 1) {
  46. if (player.hasPermission("ChatX.CmdSpy")) {
  47. if (args[0].equalsIgnoreCase("On")) {
  48. sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("CmdSpy-Enabled")));
  49.  
  50. }
  51. }
  52. }
  53.  
  54. if (args.length == 1) {
  55. if (player.hasPermission("ChatX.CmdSpy")) {
  56. if (args[0].equalsIgnoreCase("Off")) {
  57. sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("CmdSpy-Enabled")));
  58.  
  59. }
  60. }
  61. }
  62.  
  63.  
  64.  
  65.  
  66.  
  67. return true;
  68. }
  69. }
Advertisement
RAW Paste Data Copied
Advertisement