Plugin category: Chat-Related Suggested name: Mentioneer What I want: I need a plugin so that say I type in chat 'DailyLove' it turns to '&a@DailyLove&r' in chat and also makes a sound to that player mentioned in chat Preferably the NOTE_PIANO sound. Hopefully it will tag and work with everyone if they are on the server. Say There are 4 players online, player1, player2, player3, and player4. If you type those 4 names in chat they change into '&a@playername&r' Hopefully it will work flawlessly and mention players that are only online at the time. Ideas for commands: No commands needed for this plugin. Ideas for permissions: mentioneer.see: Whether that player can see tagged usernames or not. (Optional) When I'd like it by: Next Few days. Thank you
Code: @EventHandler public void onChat(AsyncPlayerChatEvent e){ for(Player on:Bukkit.getServer().getOnlinePlayers()){ if(on.equals(e.getPlayer()))continue; if(e.getMessage().contains(on.getName())){ e.setMessage(e.getMessage().replaceAll(on.getName(), ChatColor.GREEN+"@"+on.getName()+ChatColor.RESET)); on.playNote(on.getLocation(), Instrument.PIANO, Note.natural(1, Tone.A)); } } } something like that
Is it possible if I can get the full class code? Is it possible if I can get the whole java class code? Will I need two classes? One for the listener and another for the main? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
You don't need two. But you can have anywhere from '1-a crap ton' of classes depending on how you want to code it.
Is it possible if any of you can make the plugin for me? Please and thank you. RingOfStorms bobacadodl -Daily
http://dev.bukkit.org/server-mods/chatalert may not be what you want but i can make the colors configuratable
I've used ChatAlerts what I'm asking for is basically like that but I want the color customizable or to &a and not have to type the @. Say they type a name it adds the @ automatically and sounds the person. jacklin213
oh i c, ill see if anyone else wants to do this , i have exams atm and if you wanted to know yes i do have the source to the plugin but its not pretty http://github.com/jacklin213/chatalert
Wait what? I just coded Code:java package me.negative_codezZ.tagger; import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.Instrument;import org.bukkit.Note;import org.bukkit.Note.Tone;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.player.AsyncPlayerChatEvent;import org.bukkit.plugin.java.JavaPlugin; public class main extends JavaPlugin implements Listener{ @EventHandler public void onChat(AsyncPlayerChatEvent e){ for(Player on:Bukkit.getServer().getOnlinePlayers()){ Player p = e.getPlayer(); p.chat(ChatColor.translateAlternateColorCodes('&', getConfig().getString("Replace name to").replace("%name", p.getName()))); on.playNote(on.getLocation(), Instrument.PIANO, Note.natural(1, Tone.A)); } } public void onEnable() { getConfig().options().copyDefaults(true); saveDefaultConfig(); Bukkit.getServer().getPluginManager().registerEvents(this, this); } } and then it just spammed chat with me saying &a@negative_codezZ&r. Why? Any dev? In addition, it took out the rest of the text. The original message was "Hello negative_codezZ".
Problem with that? I find it working all the time and it is the main class. <Removed double post Bumping is allowed only every 24 hours - Necrodoom>
You are looping through all players and saying at every player your own name, try to modify the chat message instead of sending more chat events that are creating an infinite loop
I already fixed that problem but thanks. The issue now is that if in chat I type "Hello negative_codezZ" it will only send the message "&a@negative_codezZ&r" and not "Hello &a@negative_codezZ&r". How do I fix that timtower?
Try replacing the the name instead of making the name the only thing in the thing ( more help will go by PM )
And lower case 'M' Code:java String message = event.getMessage();Player p = event.getPlayer();message.replace("%name", ChatColor.translateAlternateColorCodes('&', getConfig().getString("Replace name to")));p.chat(message);