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.
Please add PlaceHolderAPI Support! Like {ISLAND_LEVEL} Essentials work with that
I have a problem, please help! [16:01:11 WARN]: [ChatEvents] Default system encoding may have misread config.yml from plugin jar
[16:01:11 WARN]: java.lang.IllegalArgumentException: argument type mismatch
[16:01:11 WARN]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[16:01:11 WARN]: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[16:01:11 WARN]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[16:01:11 WARN]: at java.lang.reflect.Method.invoke(Unknown Source)
[16:01:11 WARN]: at me.au2001.ChatEvents.JSONPacket.send(JSONPacket.java:22)
[16:01:11 WARN]: at me.au2001.ChatEvents.ChatEvents.handleEvent(ChatEvents.java:83)
[16:01:11 WARN]: at me.au2001.ChatEvents.ChatEvents.onAsyncPlayerChatMonitor(ChatEvents.java:74)
[16:01:11 WARN]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[16:01:11 WARN]: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[16:01:11 WARN]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[16:01:11 WARN]: at java.lang.reflect.Method.invoke(Unknown Source)
[16:01:11 WARN]: at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306)
[16:01:11 WARN]: at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
[16:01:11 WARN]: at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502)
[16:01:11 WARN]: at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:484)
[16:01:11 WARN]: at net.minecraft.server.v1_8_R3.PlayerConnection.chat(PlayerConnection.java:1084)
[16:01:11 WARN]: at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1022)
[16:01:11 WARN]: at net.minecraft.server.v1_8_R3.PacketPlayInChat$1.run(PacketPlayInChat.java:39)
[16:01:11 WARN]: at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
[16:01:11 WARN]: at java.util.concurrent.FutureTask.run(Unknown Source)
[16:01:11 WARN]: at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[16:01:11 WARN]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[16:01:11 WARN]: at java.lang.Thread.run(Unknown Source)
In reply to Forge_User_58946315:
I noticed the color/formatting codes in vault prefixes and suffixes don't carry over into the name or the chat. for example: in
{PREFIX}{PLAYER}{SUFFIX}: {MESSAGE}
, the prefix is &c but the player name is white, and the suffix is &b&o but the message is also white. I need the color/formatting codes to carry over if that's possible. Although, the per-group chat formatting you mentioned would fill the same purpose.@Tanguy72 What do you mean by "a comment"? A command?
But what would that "add" do?
Could you add a comment allowing us to do a thing like /ce add <player> <message>? is would be so cool :)
This seems like a great plugin. Too bad I never got to use it, as I got rampant error messages whenever someone used the chat. That was due to the plugin attempting to override the chat format set by GroupManager. Changing the plugins priority to "lowest" didn't help either. I had to delete the plugin, as I would never give up GM for this plugin's (much worse) chat format.
This is ridiculous.
Just about 1 month has passed and you still haven't fixed this??
I finally found a fix for that, I will implement it shortly.
"Shortly"
Oh and also, you cant click on links.
@au2001
Hi,
Please tell me when you have implemented it.
Thanks!
@mat41997 Could I see your config? It seems to contain a strange character.
@dingbran I finally found a fix for that, I will implement it shortly.
Hi,
I have an issue with Coloured text whilst using this plugin. I used "&a" for the full length of the chat bar, but it gets cut off.
Please help, I have attached a picture.
error,
@Mohmega
Yes, it does ;)
Does this work with 1.8.8?
@MrFrancy
Added this, only working if you have Multiverse-Core installed of course.
There will also be the feature @Cronos2212 suggested (per-group formats).
I'm testing just some last things and I'll release it.
Chat not working on 1.8.8 :/ damn, thought i finally found a plugin for this.
This plugin only needs {WORLD} with the color set in Multiverse config, like other chat formatting plugin
When I talk in chat with only this chat plugin loaded It doesn't show in chat? when I disable this plugin it does display in chat. This is the errors i am getting when I type http://gyazo.com/42882007b9743b4e0f9efa0a893daf9f
@Cronos2212 Well, you can use prefixes for this, but if you want several prefixes, no you can't for now :/ In GroupManager or whatever you use, you could set a prefix '[Donator] ' for your group, and then use the chat format like this: "{PREFIX} {NAME} » {MESSAGE}"
I can add a functionality to do that, would it be okay if I replace the format section in the config by this:
And then the permission to have each chat format would be ChatEvents.formar.donator etc.
If that's what you want, and you're okay with this method, I will add it today or tomorrow and update the plugin here :)