Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void playerChat(AsyncPlayerChatEvent chat) {
- chat.setCancelled(true);
- Player player = chat.getPlayer();
- User user = luckPerms.getPlayerAdapter(Player.class).getUser(player);
- String prefix = user.getCachedData().getMetaData().getPrefix();
- String suffix = user.getCachedData().getMetaData().getSuffix();
- String msg = chat.getMessage();
- String message = CityCraftChat.plugin.getConfig().getString("LocalPrefix") + " " + prefix + player.getName() + suffix + " §7» " + CityCraftChat.plugin.getConfig().getString("LocalChatColor") + msg;
- int blockDistance = CityCraftChat.plugin.getConfig().getInt("LocalChatDistance");
- int onlinePlayers = Bukkit.getOnlinePlayers().size();
- Location playerLocation = chat.getPlayer().getLocation();
- for (Player pl : chat.getRecipients()) {
- if (pl.getLocation().distance(playerLocation) <= blockDistance) {
- pl.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
- }
- if (onlinePlayers == 1) {
- player.sendMessage("§8<§c!§8> §7Nobody is online to hear you. It's a lonely world.");
- }
- }
- chat.getRecipients().clear();
- }
Advertisement
Add Comment
Please, Sign In to add comment