ChatEvents
ChatEvents
ChatEvents
ChatEvents is a very simple plugin, but that has infinite possibilities.
You can add hover and click events or insertion (shift + click will insert text in your chat bar).
This uses the tell-raw arguments to modify the chat: each time someone talks, it will replace the message by a raw message.
This message is configurable in the config under "format" (see config below). You can also create events in the config.
There even is a configurable permission to see the normal message, or the raw message (with events).
Each event has it's own unique (or not) permission, for exemple to limit a click event to moderators.
You can add events to the player name, the message, the hole line or create your own custom events on certain variables.
Here is the list of events:
- hover: Used for when the player puts his mouse over the word/sentence.
- show_text: Used to show text, can be whatever you want.
- show_item: Used to show an item.
- show_entity: Used to show an entity (e.g. {id:UUID,name:Blaze,type:BLAZE})
- show_achievement: Used to show an achievement (e.g. ?)
- click: Used for when the player clicks the word/sentence.
- suggest_command: Suggests a command in the chat bar.
- run_command: Runs a command as the player.
- open_url: Opens a URL (or the "Are you sure you want to open the following website?" prompt).
- change_page: Don't use this, it's for books, it is used to redirect to a specific page of the current book.
- insertion: Used to insert text in the chat bar when a player shift-clicks the word/sentence.
Configuration
After installing the plugin, a config.yml file will be generated like that:
format: '&7{PLAYER} &8» &f{MESSAGE}' priority: MONITOR permission: 'ChatEvents.sendJSON' events: username: hover: permission: 'ChatEvents.username.hover' action: show_text value: '&6Name: &e{USERNAME}\n&6Balance: &e{MONEY}\n&6Rank: &e{RANK}' click: permission: 'ChatEvents.username.click' action: suggest_command value: '/msg {USERNAME} Type your message here.' vars: - '{PLAYER}' - '{USERNAME}' - '{CUSTOM}' - '{TABNAME}' message: hover: permission: 'ChatEvents.message.hover' action: show_text value: '&6Click here to google this message.' disabled: true click: permission: 'ChatEvents.message.click' action: open_url value: 'http://www.google.com/?q={MESSAGE}' disabled: true vars: '{MESSAGE}' acustomevent: hover: permission: 'ChatEvents.other.hover' action: show_text value: '&6HelloWorld!' click: permission: 'ChatEvents.other.click' action: open_url value: 'http://www.google.com/?q=Hello World' vars: - '{VIEWER}' - '{VIEWERNAME}' - '{VIEWERCUSTOM}' - '{VIEWERTAB}' all: insertion: permission: 'ChatEvents.all.insertion' value: '{MESSAGE}' vars: '*'
(I removed the comments to make it easier to read)
Each time someone talks, the message will be in the format set in the "format" section.
For example, the default format will be the name of the player in gray, an arrow pointing right in dark gray and the message in white.
The "permission" part is used to determine if a player should see the events, or not.
You can also disable each event individually at any moment, just by adding "disabled: true" and reloading.
Permissions
The "permission" in the config, is the permission used to determine if a player should see the events, or not.
Then, for each individual event, you can set a permission.
For exemple, if you want normal players to be able to hover a player's name, but not click it, use something like this:
events: username: hover: permission: 'ChatEvents.username.hover' action: show_text value: '&6Name: &e{USERNAME}\n&6Balance: &e{MONEY}\n&6Rank: &e{RANK}' click: permission: 'ChatEvents.username.click' action: run_command value: '/mute {USERNAME} 15m' vars: - '{PLAYER}' - '{USERNAME}' - '{CUSTOM}' - '{TABNAME}'
And give the permission "ChatEvents.username.hover" to normal players, but not "ChatEvents.username.click".
You can use several variables, such as PLAYER, USERNAME, CUSTOM, TABNAME, WORLD or MESSAGE without any other plugin.
The variables VIEWER, VIEWERNAME, VIEWERCUSTOM and VIEWERTAB are also available and will change according to the receiver.
If you want other variables, install Vault and you will have access to MONEY, RANK, PREFIX or SUFFIX.
To insert a variable in a message, surround it with curly brackets ( {...} ) and use CAPITALS.
Developers
You have a plugin that is not supported by ChatEvents, and want to have the variables in the chat?
ChatEvents offers a VERY easy API to add your own variables!
For exemple, you have a plugin that adds tokens, and you want to show the player's tokens when you hover his name.
Then it is very easy, in your onEnable void, add this code:
Module tokensModule = new Module("tokens") { // The "tokens" part is what your variable name will be, this will give {TOKENS} @Override public String getValue (Player player, Player viewer) { String tokens = "0"; // Put the code to get the tokens of player here. return tokens; } }; Module relationModule = new Module("relation") { // This will give {RELATION} @Override public String getValue (Player player, Player viewer) { String relation = ChatColor.YELLOW + "Neutral"; // Put the code to get the relation between player and viewer here. return relation; } };
In the name of the module, you can put, or not the curly brackets ( {...} ) and put capitals or not.
But in the config, the curly brackets and the capitals are mandatory.
If you don't save this to a variable, it still works, but you won't have it saved.
Saving it to a variable can be usefull to disable it at any moment.
(for exemple when a mini-game is stopped, and your getValues would provoque errors because some variables are unloaded)
You can also add an optional "setValue" void like that:
@Override public void setValue (Player player, String tokens) { // This checks if the string tokens has the format of an integer, to prevent exceptions below. if (tokenscount.matches("\\-?[0-9]+")) { int tokenscount = Integer.parseInt(tokens); // Put the code to set the tokens of player to tokenscount here. } }
This code will never be used by ChatEvents itself, but maybe by other plugins.
After you've done that, add the variable in your config, like that for exemple:
events: tokens: hover: permission: 'ChatEvents.showTokens' action: show_text value: '&6Tokens: &e{TOKENS}' vars: '{PLAYER}'
Voila! You just created your own module for ChatEvents, and you can now use it in ChatEvents' config.
This plugin uses MetricsLite by Hidendra, collecting information which are available on mcstats.org.
Is there a way to have certain players have different chat formats? For example a normal player would have the default chat format set in this config, but a donator or staff would have "[Donator] (name) » (Message)"?
@Sora37 Have you been able to test? If so, did it work?
@au2001
Hi,
I am on Spigot-1646, using the protocol hack (allowing both 1.7 and 1.8 versions).
I will test on 1.8.3 ! :)
@RenaudRl @Sora37
You might want to try in 1.8, because your servers seam to be on 1.7.
I didn't do much test in 1.7, since I didn't have much time, and I can't code (or test) for now :/
Apparently your problem is that the Packet for chat cannot be sent, but that works fine in 1.8.
I will test ChatEvents in 1.7 as soon as I can, and try to fix it ;)
Thanks to you two for pointing out this bug, and I hope 1.8 is not a problem for you :D
(Sorry for my English, I French)
Hi, the chat doesn't work with your plugin :(
(In the end, there is my message, but in Minecraft, there isn't)
I use the default config, and I have Spigot 1.7.10: "CraftBukkit version git-Spigot-1646 (MC: 1.7.10) (Implementing API version 1.7.10-R0.1-SNAPSHOT)"
How can I solve the problem ?
Thanks you ! :)
Hello , i have a big problem :/ My config,it's basic.
[19:19:54] [Async Chat Thread - #5/WARN]: java.lang.IllegalArgumentException: argument type mismatch [19:19:54] [Async Chat Thread - #5/WARN]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [19:19:54] [Async Chat Thread - #5/WARN]: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [19:19:54] [Async Chat Thread - #5/WARN]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [19:19:54] [Async Chat Thread - #5/WARN]: at java.lang.reflect.Method.invoke(Unknown Source) [19:19:54] [Async Chat Thread - #5/WARN]: at me.au2001.ChatEvents.JSONPacket.send(JSONPacket.java:22) [19:19:54] [Async Chat Thread - #5/WARN]: at me.au2001.ChatEvents.ChatEvents.handleEvent(ChatEvents.java:83) [19:19:54] [Async Chat Thread - #5/WARN]: at me.au2001.ChatEvents.ChatEvents.onAsyncPlayerChatHighest(ChatEvents.java:49) [19:19:54] [Async Chat Thread - #5/WARN]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [19:19:54] [Async Chat Thread - #5/WARN]: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [19:19:54] [Async Chat Thread - #5/WARN]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [19:19:54] [Async Chat Thread - #5/WARN]: at java.lang.reflect.Method.invoke(Unknown Source) [19:19:54] [Async Chat Thread - #5/WARN]: at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) [19:19:54] [Async Chat Thread - #5/WARN]: at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) [19:19:54] [Async Chat Thread - #5/WARN]: at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [19:19:54] [Async Chat Thread - #5/WARN]: at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:484) [19:19:54] [Async Chat Thread - #5/WARN]: at net.minecraft.server.v1_8_R1.PlayerConnection.chat(PlayerConnection.java:1036) [19:19:54] [Async Chat Thread - #5/WARN]: at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:975) [19:19:54] [Async Chat Thread - #5/WARN]: at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:26) [19:19:54] [Async Chat Thread - #5/WARN]: at net.minecraft.server.v1_8_R1.PacketPlayInChat$1.run(PacketPlayInChat.java:47) [19:19:54] [Async Chat Thread - #5/WARN]: at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [19:19:54] [Async Chat Thread - #5/WARN]: at java.util.concurrent.FutureTask.run(Unknown Source) [19:19:54] [Async Chat Thread - #5/WARN]: at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [19:19:54] [Async Chat Thread - #5/WARN]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [19:19:54] [Async Chat Thread - #5/WARN]: at java.lang.Thread.run(Unknown Source)
PS : sorry for my bad English(i'm french)
Finally, the first release : v1.0!
Thank you all for the thousand downloads :D
I hope you will like the fixes/adds I made in this version!
I personally love them :3
And you can now use this plugin in almost any bukkit version!
Don't forget to tell me if you want something added, or if you find a bug!
Thanks again for the support, and I hope this plugin will keep on!
I personally use it for my server, and it's crazy cool! :)
v0.9 will be uploaded TOMORROW!
In the new Beta 0.9 update:
- Fixed all the bugs! (No known bug for now!)
- WAY more efficient JSON generator!
- Rewrote most of the method for maximum efficiency!
- Support for CUSTOM events!
- Per-event disable option!
- Some other changes/adds!
Note: It has been uploaded mow, thanks for the 60+ downloads ^.^
@au2001
Okay, Thank you much! I will give it another try. I actually Populated that list after I removed ChatEvents.(So sorry it wasn't in there :P I deleted bChatManager from the list but didn't readd ChatEvents to it as I had planned before sending you the plugin list.) I removed it after testing it with my chat manager removed, different permissions, negative permissions, lol. Just about everything I could think of.
Ok, Vault support is awesome! That will let me use some of the ChatTags I have from other plugins in the Chat Format, which is what I was looking for ;)
@DrkMatr1984
It already has Vault support :3
But I don't see ChatEvents in your plugin list, is that normal or did you forget to install it? ^.^
And I don't really see any of your plugins that could have a compatibility problem...
The only plugin I know of (for now) is Factions, and I am currently making a fix for that.
If it is normal, then it might be a problem with one of your plugins I never tested...
How about you try doing /plugman disable all and then /plugman enable ChatEvents and see if it works?
And for MarriageMaster, it shouldn't cause any problem...
But you might want to make a Module to have the heart (or not) ;)
EDIT: I uploaded the version with the fix (v0.7 since 0.6 is bugged :s)
Download the latest version and try to set the priority to HIGHEST if what I said above doesn't work.
I hope that'll fix your problem, but if it doesn't please tell me, and I will try to find a fix, or come on your server to try fixing it directly.
Hey, I can't seem to get the formatting to work or the events. Everything loads fine, but I can't get the format to appear correctly, hence no chatevents. I've disabled EssentialsChat completely, as we switched to bChatManager. So I attempted to remove bChatManager and just let your plugin handle the chats, but I get the default chat format of bukkit instead. Here's a list of my plugins, and you should add Vault Support!
I've also been in and out of the essentials config disabling any chat related features. Like I said, we switched to bChatManager, so I had to do all of those things to get that to work correctly. I do have some plugins that don't "modify chat format" but add this to the existing chat format. (Like MarriageMaster, if you're married it adds a heart in front of your name)
Gonna give this a try!
Looks great!