SHARE
TWEET

Untitled

a guest Jul 17th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package events;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.entity.Player;
  6. import org.bukkit.event.EventHandler;
  7. import org.bukkit.event.EventPriority;
  8. import org.bukkit.event.Listener;
  9. import org.bukkit.event.player.AsyncPlayerChatEvent;
  10.  
  11. import ccx.Main;
  12. import me.clip.placeholderapi.PlaceholderAPI;
  13. import net.md_5.bungee.api.chat.ComponentBuilder;
  14. import net.md_5.bungee.api.chat.HoverEvent;
  15. import net.md_5.bungee.api.chat.TextComponent;
  16.  
  17. public class PChat implements Listener {
  18.     public PChat() {
  19.         Main.instance.getServer().getPluginManager().registerEvents(this, Main.instance);
  20.     }
  21.    
  22.     public static boolean ChatEnabled = true;
  23.    
  24.     @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
  25.     public void onChat(AsyncPlayerChatEvent e){
  26.         if(ChatEnabled == false) {
  27.             if(!e.getPlayer().hasPermission(Main.config.getString("Settings.MuteChatBypassPerm"))) {
  28.                 e.setCancelled(true);
  29.             } else {
  30.                 if(e.getPlayer().isOp()) {
  31.                     String OP_OPPrefix_Format = Main.config.getString("Chat.OP.OPPrefix.Format");
  32.                     String OP_OPPrefix_Hover = Main.config.getString("Chat.OP.OPPrefix.Hover");
  33.                    
  34.                     String OP_Prefix_Format = Main.config.getString("Chat.OP.Prefix.Format");
  35.                     String OP_Prefix_Hover = Main.config.getString("Chat.OP.Prefix.Hover");
  36.                    
  37.                     String OP_Name_Format = Main.config.getString("Chat.OP.Name.Format");
  38.                     String OP_Name_Hover = Main.config.getString("Chat.OP.Name.Hover");
  39.                    
  40.                     String OP_Message_Format = Main.config.getString("Chat.OP.Message.Format");
  41.                     String OP_Message_Hover = Main.config.getString("Chat.OP.Message.Hover");
  42.                    
  43.                     String OPPAPI_OPPrefix_Format = PlaceholderAPI.setPlaceholders(e.getPlayer(), OP_OPPrefix_Format);
  44.                     String OPPAPI_Prefix_Format = PlaceholderAPI.setPlaceholders(e.getPlayer(), OP_Prefix_Format);
  45.                     String OPPAPI_Name_Format = PlaceholderAPI.setPlaceholders(e.getPlayer(), OP_Name_Format);
  46.                    
  47.                     String OPPAPI_OPPrefix_Hover = PlaceholderAPI.setPlaceholders(e.getPlayer(), OP_OPPrefix_Format);
  48.                     TextComponent OP_OPP_Hover = new TextComponent(OP_OPPrefix_Hover);
  49.                     OP_OPP_Hover.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(OPPAPI_OPPrefix_Hover).create()));
  50.                    
  51.                     String OPPAPI_Prefix_Hover = PlaceholderAPI.setPlaceholders(e.getPlayer(), OP_Prefix_Format);
  52.                     TextComponent OP_P_Hover = new TextComponent(OP_Prefix_Hover);
  53.                     OP_OPP_Hover.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(OPPAPI_Prefix_Hover).create()));
  54.                    
  55.                     String OPPAPI_Name_Hover = PlaceholderAPI.setPlaceholders(e.getPlayer(), OP_Name_Format);
  56.                     TextComponent OP_N_Hover = new TextComponent(OP_Name_Hover);
  57.                     OP_OPP_Hover.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(OPPAPI_Name_Hover).create()));
  58.                    
  59.                     String message = OP_Message_Format.replaceAll("%message%", e.getMessage());
  60.                    
  61.                     e.setFormat(OP_OPP_Hover + OP_P_Hover + OP_N_Hover + message);
  62.                 } else {
  63.                    //
  64.                 }
  65.             }
  66.             } else if(ChatEnabled == true) {
  67.                 //
  68.             }
  69.     }
  70. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top