diff --git a/src/cz/marwland/mc/core/MarwCore.java b/src/cz/marwland/mc/core/MarwCore.java index 443e806..8c97fe8 100644 --- a/src/cz/marwland/mc/core/MarwCore.java +++ b/src/cz/marwland/mc/core/MarwCore.java @@ -8,6 +8,7 @@ import cz.marwland.mc.core.config.ConfigManager; import cz.marwland.mc.core.features.Base; import cz.marwland.mc.core.features.Feature; import cz.marwland.mc.essentials.features.Borders; +import cz.marwland.mc.essentials.features.ChatNotifier; public class MarwCore extends JavaPlugin { @@ -22,6 +23,7 @@ public class MarwCore extends JavaPlugin { this.addFeature(new Base(this)); this.addFeature(new Borders(this)); + this.addFeature(new ChatNotifier(this)); configManager.load(); this.features.forEach((k, v) -> v.onEnable()); diff --git a/src/cz/marwland/mc/essentials/features/ChatNotifier.java b/src/cz/marwland/mc/essentials/features/ChatNotifier.java index 23e3b76..37836d1 100644 --- a/src/cz/marwland/mc/essentials/features/ChatNotifier.java +++ b/src/cz/marwland/mc/essentials/features/ChatNotifier.java @@ -1,7 +1,13 @@ package cz.marwland.mc.essentials.features; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.AsyncPlayerChatEvent; + import cz.marwland.mc.core.MarwCore; import cz.marwland.mc.core.features.Feature; +import net.md_5.bungee.api.ChatColor; public class ChatNotifier extends Feature { @@ -9,4 +15,17 @@ public class ChatNotifier extends Feature { super(plugin, null); } + @EventHandler + public void onPlayerChat(AsyncPlayerChatEvent e) { + e.setCancelled(true); + for (Player p : plugin.getServer().getOnlinePlayers()) { + String msg = e.getMessage(); + if (e.getMessage().toLowerCase().contains(p.getName().toLowerCase())) { + msg = ChatColor.RED + msg; + // ActionBarAPI.sendActionBar(p, ChatColor.RED + "Byl jsi zminen v chatu", 80); + p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 3.0F); + } + p.sendMessage(String.format(e.getFormat(), e.getPlayer().getDisplayName(), msg)); + } + } }