Advertisement
Guest User

Updated Staffchat

a guest
Aug 25th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. package MainPack;
  2.  
  3. import java.io.PrintStream;
  4. import java.util.HashMap;
  5. import java.util.Set;
  6. import org.bukkit.Server;
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.event.EventHandler;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.event.player.AsyncPlayerChatEvent;
  13. import org.bukkit.event.player.PlayerQuitEvent;
  14. import org.bukkit.plugin.Plugin;
  15. import org.bukkit.plugin.PluginManager;
  16. import org.bukkit.plugin.java.JavaPlugin;
  17.  
  18. public class staffchat extends JavaPlugin
  19. {
  20. HashMap<Player, String> map = new HashMap();
  21. String pre;
  22.  
  23. public staffchat() {
  24. this.pre = this.c("&9StaffChat &5>>&7 ");
  25.  
  26. }
  27.  
  28. public void onLeave(PlayerQuitEvent e) {
  29. if (this.map.containsKey((Object)e.getPlayer())) {
  30. this.map.remove((Object)e.getPlayer());
  31. }
  32. }
  33.  
  34. @EventHandler
  35. public void onChat(AsyncPlayerChatEvent e) {
  36. Player p = e.getPlayer();
  37. if (this.map.containsKey((Object)p)) {
  38. for (Player ply : this.map.keySet()) {
  39. if (!this.map.get((Object)ply).equalsIgnoreCase(this.map.get((Object)p))) continue;
  40. if (this.map.get((Object)ply).equalsIgnoreCase("staff chat")) {
  41. ply.sendMessage(String.valueOf(this.c(new StringBuilder("&9Staff Chat &5>> &4").append(p.getName()).append("&c&l: ").toString())) + e.getMessage());
  42. continue;
  43. if (p.hasPermission("staffchat.read"));
  44. ply.sendMessage(String.valueOf(this.c(new StringBuilder("&9Staff Chat &5>> &4").append(p.getName()).append("&c&l: ").toString())) + e.getMessage());
  45.  
  46.  
  47.  
  48. ply.sendMessage(String.valueOf(this.pre) + this.c(new StringBuilder("&2").append(p.getName()).append("&7: ").append(e.getMessage()).toString()));
  49. }
  50. e.setCancelled(true);
  51. }
  52. }
  53. }
  54.  
  55. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  56. String cmd = command.getName();
  57. if (sender instanceof Player) {
  58. Player p = (Player)sender;
  59. if (p.hasPermission("staffchat.toggle") && (cmd.equalsIgnoreCase("sc") || cmd.equalsIgnoreCase("staffchat"))) {
  60. if (this.map.containsKey((Object)p)) {
  61. for (Player ply : this.map.keySet()) {
  62. if (!this.map.get((Object)ply).equalsIgnoreCase(this.map.get((Object)p))) continue;
  63. ply.sendMessage(String.valueOf(this.pre) + this.c(new StringBuilder("The Player ").append(p.getName()).append(" has left the Staff Chat!").toString()));
  64. }
  65. this.map.remove((Object)p);
  66. p.sendMessage(String.valueOf(this.pre) + this.c("You are nolonger in the Staff Chat!"));
  67. } else {
  68. this.map.put(p, "staff chat");
  69. for (Player ply : this.map.keySet()) {
  70. if (!this.map.get((Object)ply).equalsIgnoreCase("staff chat")) continue;
  71. ply.sendMessage(String.valueOf(this.pre) + this.c(new StringBuilder("The Player ").append(p.getName()).append(" has joined the Staff Chat!").toString()));
  72. }
  73. p.sendMessage(String.valueOf(this.pre) + this.c("Now you are in the Staff Chat!"));
  74. }
  75. }
  76. }
  77. return true;
  78. }
  79.  
  80. public String c(String msg) {
  81. return msg.replaceAll("&", "\u00a7");
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement