-
-
Notifications
You must be signed in to change notification settings - Fork 356
ChatControlRed as TownyChat replacement instructions
Note 1: ChatControlRed currently only supports Town, Nation and Alliance chats.
Note 2: TownyChat will have to be uninstalled for this to work properly.
Go to home/commands.yml file in your root folder and create these custom commands:
command-block-overrides: []
ignore-vanilla-permissions: false
aliases:
g:
- channel send standard $1-
tc:
- channel send town $1-
nc:
- channel send nation $1-
ac:
- channel send ally $1-
Commands: /g for General/Global chat, /tc for Town Chat, /nc for Nation Chat and /ac for Alliance Chat respectively.
Go to home/plugins/ChatControlRed/settings.yml and create the channels:
Note: In my case, I use the default standard channel as the General/Global chat, but you can use the global channel or any other really if you prefer that already exists in the default settings.yml file of ChatControlRed, up to you!
List:
standard:
Format: chat
Format_Spy: '@noprefix chat'
town:
Format: town-chat
Party: towny-town
nation:
Format: nation-chat
Party: towny-nation
ally:
Format: ally-chat
Party: towny-ally
The Party values correspond to the appropriate faction of the chat itself and it's an existing feature in ChatControlRed "towny-town" is for Town Chat, "towny-nation" is for Nation Chat & "towny-ally" is for Alliance Chat respectively.
Now that you have created the channels, you'll notice that in the Format: we've declared a different format for each one of them. The format files don't exist with the exception of the default chat of ChatControlRed.
What you can do is to duplicate this file, rename it to the appropriate channel (e.g. town-chat) and set the prefix (how the chat will look when a user types in the channel) with how you want it to. Example given below for the Town Chat:
home/plugins/ChatControlRed/formats/town-chat.yml
prefix:
Message: '&7[&bTC&7] '
Personally I made it look similar (not completely identical though) to how TownyChat itself looks
Now go to home/plugins/ChatControlRed/rules/command.rs
in order to create the rules for the commands that we created on Step 1 to work properly and add these:
Note: I use the names of the channels as they were created in Step 2 for the rules to work, if you use different names, you'll need to edit the rules below accordingly.
# -------------------------------------------------------------------------------
# Create /g, /tc, /nc & /ac commands that toggle & sends messages to those channels.
# -------------------------------------------------------------------------------
#Catch "/g" and join the standard channel.
match ^([/]g)$
dont verbose
strip colors false
strip accents false
then command channel join standard
then deny
#Catch "/tc" and join the town channel.
match ^([/]tc)$
dont verbose
strip colors false
strip accents false
then command channel join town
then deny
#Catch "/nc" and join the nation channel.
match ^([/]nc)$
dont verbose
strip colors false
strip accents false
then command channel join nation
then deny
#Catch "/ac" and join the ally channel.
match ^([/]ac)$
dont verbose
strip colors false
strip accents false
then command channel join ally
then deny
#Catch "/g <message>" and redirect to the standard channel.
match ^([/]g) (.*)
dont verbose
strip colors false
strip accents false
then command channel send standard $2
then deny
#Catch "/tc <message>" and redirect to the town channel.
match ^([/]tc) (.*)
dont verbose
strip colors false
strip accents false
then command channel send town $2
then deny
#Catch "/nc <message>" and redirect to the nation channel.
match ^([/]nc) (.*)
dont verbose
strip colors false
strip accents false
then command channel send nation $2
then deny
#Catch "/ac <message>" and redirect to the ally channel.
match ^([/]ac) (.*)
dont verbose
strip colors false
strip accents false
then command channel send ally $2
then deny
Now when you execute for example the command /tc, you will join the town channel and you execute the command /tc message it will redirect the message to the town channel but won't make you join in it.
Assign the required permissions for the player group via your Permissions plugin in order for them to have access to your General/Global channel:
For General/Global chat I use the standard channel, replace it with what you wish to use instead of.
- chatcontrol.channel.autojoin.standard.read
- chatcontrol.channel.autojoin.standard.write
- chatcontrol.channel.join
- chatcontrol.channel.join.standard.read
- chatcontrol.channel.join.standard.write
- chatcontrol.channel.leave
- chatcontrol.channel.send
- chatcontrol.channel.send.standard
- chatcontrol.chat.read
- chatcontrol.chat.write
Go to home/plugins/Towny/settings/townyperms.yml
and add these permission nodes:
Under the towns category, add these permissions for the default
group:
- chatcontrol.channel.autojoin.town.read
- chatcontrol.channel.join.town.read
- chatcontrol.channel.join.town.write
- chatcontrol.channel.send.town
And finally, under the nations category, add these permission nodes for the default
group:
- chatcontrol.channel.autojoin.nation.read
- chatcontrol.channel.join.nation.read
- chatcontrol.channel.join.nation.write
- chatcontrol.channel.send.nation
- chatcontrol.channel.autojoin.ally.read
- chatcontrol.channel.join.ally.read
- chatcontrol.channel.join.ally.write
- chatcontrol.channel.send.ally
Go to home/plugins/ChatControlRed/rules/chat.rs
and add these rules:
# -------------------------------------------------------------------------------
# Kick townless/nationless users from the town, nation and ally channels
# -------------------------------------------------------------------------------
match ^.*
require channel town
ignore perm towny.chat.town
then replace
then console ch leave town {player}
then console ch join standard write {player}
then warn &cYou are no longer in a town.
match ^.*
require channel nation
ignore perm towny.chat.nation
then replace
then console ch leave nation {player}
then console ch join standard write {player}
then warn &cYou are no longer in a nation.
match ^.*
require channel ally
ignore perm towny.chat.alliance
then replace
then console ch leave ally {player}
then console ch join standard write {player}
then warn &cYou are no longer in a nation.
These rules only apply if a user has already joined in the corresponding chat, if they are only in standard, they won't trigger and won't have to.
These rules ignore users that have the permissions, meaning they'll only be active for townless and/or nationless users.
If the rule triggers, it will replace the user's text with nothing, meaning it will delete the message they'll try to type in the channel that they shouldn't belong to anymore.
Once the rule triggers, it will force kick the user from the corresponding channel and add them to the standard channel.
It will then print a message in chat to the user "You are no longer in a town/nation", you can change that or even remove it completely.
If you are using the DiscordSRV's feature with ChatControlRed, you'll need to add an extra line in the rules ignore discord
, or else whenever someone is typing a message through Discord, it will produces errors in the console. It should look like this:
match ^.*
require channel town
ignore discord
ignore perm towny.chat.town
then replace
then console ch leave town {player}
then console ch join standard write {player}
then warn &cYou are no longer in a town.
Credit to mindifirollneed and plonkatronix who figured this out.
- Home
- FAQ
- How Towny Works - Comprehensive guide for admins & players.
- Video Tutorials - Watch and learn with Major Graft.
- TownyAPI - Guide for plugin developers.
- Discord - Get involved with other Towny Admins, Plugin Developers, Testers. Support, General Discussion welcome.
- Troubleshooting
- Github Tickets
- Sponsor LlmDl - Support your developer.