ChatNotifier: finished
This commit is contained in:
parent
b4d9776a19
commit
44556d788e
@ -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());
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user